Question
1. How would the loop codes including any required and/or dependent variables for the following look like?: Count down from 10 to Blast Off!, printing
1. How would the loop codes including any required and/or dependent variables for the following look like?:
- Count down from 10 to Blast Off!, printing each number on its own line. Use a while loop.
- Count down from 10 to Blast Off!, printing each number on its own line. Use a for loop instead.
- Replace the lowercase letter e from each user-entered String, replacing it with an underscore and printing the new String. Allow the user to enter as many Strings as they want. Choose a good sentinel value.
- Count up by a given number from 0 to another given number. For example, the user may enter 5 and 30 and the loop should produce: 5, 10, 15, 20, 25, 30 then stop.
- How would a for loop that adds the even numbers from 0 to 100, then prints the final result only look like?
2. Alex needs to write two programs where one with the main method (Garage.java) uses an ArrayList of objects to contain several cars. He needs to ensure the user is able to add a car to the garage, print the contents of the garage, get the value of the cars in the garage, and remove (such as selling) a car from the garage. While the Cars.java class includes the attributes of cars such as its price. What would the getters and setters look like and how to write the toString() method appropriately so when he wants to print a car, it makes sense to the user?
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started