Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please answer to all the questions below: QUESTION 1 : Suppose that we have the following piece of the code in main ( ) float

Please answer to all the questions below:
QUESTION 1:
Suppose that we have the following piece of the code in main()
float decimalNum1, decimalNum2;
Scanner keyboard = new Scanner(System.in);
System.out.println(Enter a decimal number: );
decimalNum1= keyboard.nextFloat();
Continue providing an if STATEMENT that assigns 23.46 to decimalNum2 when decimalNum1 is greater than 46.92
QUESTION 2:
Suppose that we have the following piece of the code in main()
float decimalNum1, decimalNum2;
Scanner keyboard = new Scanner(System.in);
System.out.println(Enter a decimal number: );
decimalNum1= keyboard.nextFloat();
Continue providing an if..else STATEMENT that assigns 46.92 to decimalNum2 when decimalNum1 is greater than or equal to 92.84 otherwise assign 84.68 to decimalNum2
QUESTION 3:
Using the following chart, write an if..else..if STATEMENT to select the rate depending on the sale amount listed on the left column:
Sale Amount Commission Rate
Less than or equal $80001.99%
Greater $10000 and up to $120002.59%
Over $120003.29%
QUESTION 4:
Suppose we have the following lines of code in main()
int integerNum1, integerNum2;
Scanner keyboard = new Scanner(System.in);
System.out.println(Enter a number: );
integerNum1= keyboard.nextInt();
System.out.println(Enter another number: );
integerNum2= keyboard.nextInt();
Continue providing a NESTED IF STATEMENT that performs the following
When integerNum1 is greater 553 and integerNum2 is greater than 678
And when integerNum1 is greater than integerNum2
then display the message:
integerNum1 and integerNum2 are greater than 678 and integerNum1 is greater than integerNum2
QUESTION 5:
Suppose we have the following lines of code in main()
int option;
System.out.println(MENU OF TASKS
+1.Option 1
+2.Option 2
+3.Option 3
+0.Exit.
;
System.out.println(Enter a number from 1 to 3 to select an option or 0 to Exit);
option = keyboard.nextInt();
if (option ==1)
{
System.out.println(You select OPTION 1) ;
}
else if (option ==2|| option ==3)
{
System.out.println(You select OPTION 2 or OPTION 3);
}
else if (option ==0)
{
System.out.println(Your select EXIT.);
}
else
{
System.out.println(Invalid option);
}
Question: Convert the above if..else..if STATEMENT into a SWITCH STATEMENT

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Seven Databases In Seven Weeks A Guide To Modern Databases And The NoSQL Movement

Authors: Luc Perkins, Eric Redmond, Jim Wilson

2nd Edition

1680502530, 978-1680502534

More Books

Students also viewed these Databases questions

Question

How will these issues affect the grade levels you will teach?

Answered: 1 week ago

Question

=+2. What is the difference between brand voice and tone?

Answered: 1 week ago