Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

-Using if, if-else, iH-else-if statement, switch statement How to manage the output with a number of decimal digits by using DecimalFormat Write the Java statements

image text in transcribed

-Using if, if-else, iH-else-if statement, switch statement How to manage the output with a number of decimal digits by using DecimalFormat Write the Java statements of the following situations: Write the Java statements of the following situations: Question 1: Write an if statement that assigns 25 to variable2 when variable1 is equal to7 Quesiton 2: Write an if-else statement that assigns 4.6 to tempi when temp2 is equal to 9.2, otherwise it should assign 2.3 to temp1 Question 3: Using the following chart, write an if-else-if statement that assigns 4%, 6%, or 8% tocommission rate, depending on the value in sales Sales Over $25,000 Greater $10,000 to $25,000 Less than and equal to $10,000 Commlssion Rate 6% 4% 2% Question 4: Write nested if statement that perform the following tests: If sale1 is greater than 1500 and sale2 is greater than and equal 2500, if sale2 is less than salei then display the "Sale product 2" otherwise display the "Sale product 1 Question 5: Write an if statement that prints the message "The grade is A" if the variable score is greater or equal to 90 and less than and equal to 100 an if statement that prints the message "The number is valid if the variable number is within the range -32 through 273 Question 7: Notes: In java, to compare 2 Strings, we use the method compareTol) string1.compareTo(string20 string1 and string2 are the same stringi compare To(string2) -0 string1 is greater thant string 2 in alphabetical order. We have "string 1, string 2Otherwise, we have "string 2, string 1 Write an if-else statement that displays the String object stringi and string2 in ascending alphabetical order Question 8: Convert the follawing if-else-if statement into a switch statement #1select " 1 II select " 2 2

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

Step: 3

blur-text-image

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

More Books

Students also viewed these Databases questions