Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write a simple Java program with the following naming structure: Open Eclipse Create a workspace called hw1 Create a project called hw1 (make sure you
Write a simple Java program with the following naming structure:
- Open Eclipse
- Create a workspace called hw1
- Create a project called hw1 (make sure you select the Use project folder as root for sources and class files)
- Create a class called Hw1 in the hw1 package (make sure you check the box that auto creates the main method).
- Add a comment to the main that includes your name
Write code that demonstrates the use of each of the following basic Java commands.
Before each line or block of code add a comment with the number of the task. For example, 1. below might look like this:
//1 System.out.print("this is the easiest homework assignment ever!");
- System.out.print
- System.out.println
- Outputting a string literal
- Using "\t" and " "
- Using + to concatenate two things inside a print
- Creating an int, double, boolean and char primitive variables
- Storing values into the previous variables
- Creating a String object
- Storing a string into the String object
- Print all of the previously created variables and the String object and separated by tabs
- Show how to make a variable a constant
- Create a Scanner object
- Use the Scanner object to read from the keyboard an int, double, char and String and store the values into the previously declared variables. (char is difficult. Research / Google how to do this...)
- Print the variables again, and separated by tabs
- Use three of the Math class methods
- Create a use a Random object to print a random number between 10 and 20 inclusively
- Show an example of data type conversion without explicit casting
- Show an example of data type conversion with casting
- Show the use of an if statement comparing two primitives
- Show the use of the .equals() method inside an if statement to compare two Strings
- Show the use of an if-else statement
- Use a For loop to print the numbers from 1 to 20 inclusively and all on the same line
- Use a While loop to print the even numbers from 1 to 61 and all on the same line
- Use a Do-While loop to prompt the user to enter an odd positive number
- Create an int array that can hold 100 values. Fill it will random numbers between 0 and 300.
- Find and print the smallest number in the int array.
- Find and print the average of the numbers in the int array.
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