In this lab you will get practice with:
In this task we will write α better version of the
Intro class .
Start with this version of the
Introduction.java program. Make the necessary
changes so that the program asks the user for their name, year of graduation, their money and
whether they are cs majos or not. It reads the user's answers as they type them in.
Finally, the program produces a paragraph, summarizing this information,
and presents it to the user.
Use Java's built-in
The Scanner class, which is part of the
standard Java class library (java API), provides methods for reading input values.
( Fetch or
on your mac. From the cs230/download directory, download lab1 folder to your desktop.
lab1 so its name contains your and your partner's usernames,
lab1_skakavou_jherbst. In BlueJ create a new project, named
Lab1Project, where you will add the classes you will create today for this lab.
In this task, you will define a class named Height. Your program will:
As you compile your program, it is likely that some error messages (syntax errors) will be generated. Read each one carefully, as you try to debug your program.
Write a program, named
Assume that users who have turned 18 in November of this year are considered eligible for voting.
Write a class, named
Dice, which simulates rolling a die twice. Assume that
the possible values when rolling a die are in the range [1..6]. The program should produce
an output like this:
You rolled a 3 and a 5.
Write a program, named
Assume that the user's last name has length >= 5. This version does not need to deal with duplicate user names.
Write an other version of the previous program, named
continue prompting the user for their name information, and then producing user names
until the user chooses to stop the process. Use a loop and a sentinel value to achieve this.
Try to write two versions, one using a while and one a do-while loop.
You can start with any design you can come up with. But at the end, try to have the following methods defined and properly invoked:
1. public static String produceFirstPart() 2. public static int produceSecondPart() 3. public static String produceOneUserName() //this method calls the previous two
main() method, as always, should be high-level and short: It should
only contain the top-level loop, which drives the whole process, and make calls to the
methods defined earlier.
Consult the instructions in last week's lab, as you need. At the end, check to verify that your work has been uploaded properly in both partners accounts.