JAVA
In this assignment, you'll write aWelcome to Data Structuresapp. This will give you
the chance to practice getting input from the user via the Scanner class and to try out
conditionals and loops. You should put the code for this part of the assignment in
Welcome.java. You're welcome to make your program object oriented like the Guessing
Game we did in class, or to have all of your code inside the main method. Your program
should first print "Welcome to Data Structures!" and then prompt the user for their
name. After prompting the user for their name, ask the user to put in their favorite
number. Then, the program should print "Welcome [name].", where [name] is the name
the user typed in. After printing the welcome line, the program should print lines
counting down by three from the favorite number if the number was positive, or counting
up by two if the favorite number was negative. The program should stop printing
numbers after it crosses 0. Right before the program is finished, it should print a fun fact
of your choosing. For example, if I chose the favorite number of 7.33, the program
would print:
Welcome Yucong.
7.33
4.33
1.33
Giraffes are my favorite animal. Did you know that there are
actually four separate species of giraffe?
If I chose the favorite number -6, the program would print:
Welcome Yucong.
-6.0
-4.0
-2.0
0.0
Giraffes are my favorite animal. Did you know that there are
actually four separate species of giraffe?
There's no need to worry too much about number formatting, although you're welcome
to play around with it.
Note that the way Java represents doubles, you'll occasionally get small errors, so you
might code everything right and see output like:
Welcome to Data Structures!
Type your name: Yucong
Type your favorite number: 5.233
Welcome Yucong.
5.233
2.2329999999999997