Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Please help answering the 3 questions Java Control Flow Exercise 1. Create a new Java class called ControlFlowExercise. 2. In the main method, create an
Please help answering the 3 questions
Java Control Flow Exercise 1. Create a new Java class called "ControlFlowExercise". 2. In the main method, create an integer variable called "number" and set its value to 10. 3. Use an if statement to check whether "number" is greater than 0 . If it is, print the message "The number is positive." If it is not, print the message "The number is not positive.". 4. Use an if-else statement to check whether "number" is even or odd. If it is even, print the message "The number is even." If it is odd, print the message "The number is odd.". 20.". 6. Create a for loop that counts from 1 to 5 , and prints the value of the loop variable at each iteration. 7. Create a while loop that counts down from 10 to 1 , and prints the value of the loop variable at each iteration. 8. Create a do-while loop that prompts the user to enter a number, and continues prompting the user until they enter a number greater than or equal to 10. Java Operators 2 Exercise 1. Create a new Java class called "JavaOperators2". 2. In the main method, create two integer variables called "x" and "y", and set their values to 5 and 3 , respectively. 3. Use the addition operator to add x and y, and assign the result to a new variable called "sum". 4. Use the subtraction operator to subtract y from x, and assign the result to a new variable called "difference". 5. Use the multiplication operator to multiply x and y, and assign the result to a new variable called "product". 6. Use the division operator to divide x by y, and assign the result to a new variable called "quotient". 7. Use the modulus operator to calculate the remainder when x is divided by y, and assign the result to a new variable called "remainder". 8. Use the increment operator to increase the value of x by 1 . 9. Use the decrement operator to decrease the value of y by 1. 10. Use the logical AND operator to compare whether x is greater than y AND whether y is less than x, and assign the result to a new variable called "resul 11. Print out the values of all the variables you created in steps 3-10. Your task in this exercise is to build a program that can convert temperatures between Celsius and Fahrenheit. The program will take user input for a temperature and the desired conversion direction, and then output the converted temperature. Here are the steps: 1. Create a new Java class called "TemperatureConversion". 2. In the main method, use a Scanner object to ask the user for a temperature and the desired conversion direction (Celsius to Fahrenheit or Fahrenheit to Celsius). 3. Implement conditional statements to perform the selected conversion using the appropriate arithmetic formula. 4. Display the converted temperature to the user. 5. The formulas for conversion are: - Celsius to Fahrenheit: F=(C9/5)+32 - Fahrenheit to Celsius: C=(F32)5/9Step 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