Docsity

Welcome to Data Structures app, Assignments of Java Programming

Toggle sidebar
bg1
JAVA
In this assignment, you'll write aWelcome to Data Structuresapp. 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
pf3

Partial preview of the text

Download Welcome to Data Structures app and more Assignments Java Programming in PDF only on Docsity!

JAVA

In this assignment, you'll write a Welcome to Data Structures app. 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.

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.

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.

Welcome Yucong.

Giraffes are my favorite animal. Did you know that there are

actually four separate species of giraffe?

REQUIREMENTS:

1. Program compiles: For all of the assignments in this class, it is vital that your

program compiles.

2. Program runs correctly on test input.

3. Program uses Scanner.

4. Program correctly prints for positive and negative numbers.

5. Appropriate comments are used to indicate the logic of the program.

6. Program is named "Welcome". Please make sure to always use the names given

in assignment descriptions.

7. Program uses correct indentation.

8. Program follows typical Java style rules about naming variables (e.g.,

myVariableName).