I have a class called CS160 and it\'s all about (JavaProgramming). I have this h
ID: 3609097 • Letter: I
Question
I have a class called CS160 and it's all about (JavaProgramming).I have this homework that was pretty tuff for me to do and WE USEECLIPSE SOFTWARE to we write the inputs for programming. we have something called MADELIBS which is what I want to getfor the output and its format as followed: ( The madlib story is asfollows): Itwas a warm and [adjective] night. [Name] was out [hobby] under the [color] glow of themoonlight. Suddenly, out of nowhere [first digit of birth year and lastdigit of birth year] [insects] attacked [Name] ! [Name] looked across the field, and saw [# characters of Name]trees about [# characters of insects] yards away. Here is an example of what the output would be if weprogram: What is your name? Elizabeth Give me an adjective : fuzzy What is your favorite hobby? skiing What is your favorite color? green What is your least favorite insect (specify the plural) ?spiders What year were you born? 1987 the story about this girl's informationin the output in eclipse would be as: It was a warm and fuzzynight. Elizabeth was out skiing under the greenglow of the moonlight. Suddenly, out of nowhere 17 spidersattacked Elizabeth! Elizabeth looked across the field, andsaw 9 trees about 7 yards away. While programming in Eclipse, I must use Scanner for the input. My question is how do I program and what should I put in theinput in order to get the madlib story for my information? I would apprciate your help. Thank you. I have a class called CS160 and it's all about (JavaProgramming).
I have this homework that was pretty tuff for me to do and WE USEECLIPSE SOFTWARE to we write the inputs for programming. we have something called MADELIBS which is what I want to getfor the output and its format as followed: ( The madlib story is asfollows): Itwas a warm and [adjective] night. [Name] was out [hobby] under the [color] glow of themoonlight. Suddenly, out of nowhere [first digit of birth year and lastdigit of birth year] [insects] attacked [Name] ! [Name] looked across the field, and saw [# characters of Name]trees about [# characters of insects] yards away. Here is an example of what the output would be if weprogram: What is your name? Elizabeth Give me an adjective : fuzzy What is your favorite hobby? skiing What is your favorite color? green What is your least favorite insect (specify the plural) ?spiders What year were you born? 1987 the story about this girl's informationin the output in eclipse would be as: It was a warm and fuzzynight. Elizabeth was out skiing under the greenglow of the moonlight. Suddenly, out of nowhere 17 spidersattacked Elizabeth! Elizabeth looked across the field, andsaw 9 trees about 7 yards away. While programming in Eclipse, I must use Scanner for the input. My question is how do I program and what should I put in theinput in order to get the madlib story for my information? I would apprciate your help. Thank you. My question is how do I program and what should I put in theinput in order to get the madlib story for my information? I would apprciate your help. Thank you.
Explanation / Answer
please rate - thanks import java.util.*; public class madlibs {public static void main(String[] args) {Scanner in = newScanner(System.in); Stringname,adjective,hobby,color,insect; int birthyear,number; System.out.print("What isyour name? "); name=in.next(); System.out.print("Give me anadjective: "); adjective=in.next(); System.out.print("What is yourfavorite hobby? "); hobby=in.next(); System.out.print("What isyour favorite color "); color=in.next(); System.out.print("What isyour least favorite insect (specify the plural)? "); insect=in.next(); System.out.print("What yearwere you born? "); birthyear=in.nextInt(); System.out.println("It was awarm "+adjective+" night"); System.out.println(name+"was out "+hobby+" under the "+color+" glow of the moonlight."); number=birthyear/1000*10+birthyear%10; System.out.println("Suddenly, out of nowhere "+number+" "+insect+"attacked "+name+"!"); System.out.println(name+"looked across the field, and saw "+name.length()+" trees about"+insect.length()+" yards away."); } }
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.