Question

In: Computer Science

1. Assume that total has already been declared as a double variable and received a value,...

1. Assume that total has already been declared as a double variable and received a value, and discountRate has been declared as a double variable, you don’t need to declare them again. You write one if statement (not multiple individual if statements) for following requirements.

when total is less than 50, set discountRate to 0.0;

when total is equal to or greater than 50 and less than 100, set discountRate to 0.05;

when total is equal to or greater than 100, set discountRate to 0.1.

in java

Solutions

Expert Solution

Java code:

public class Main
{
   public static void main(String[] args){
        //initializing sample total and discountRate(only for you understanding)
       double total=50,discountRate;
       //checking if total is greater than or equal to 100
       if(total>=100)
       //setting discountRate as 0.1
            discountRate=0.1;
       //checking if total is greater than or equal to 50
       else if(total>=50)
       //setting discountRate as 0.05
            discountRate=0.05;
       else
       //setting discountRate as 0.0
            discountRate=0.0;
       //printing discountRate(only for you understanding)
       System.out.println("discountRate="+discountRate);
   }
}


Screenshot:


Output:


Related Solutions

Assume that an int variable age has been declared and already given a value and assume...
Assume that an int variable age has been declared and already given a value and assume that a char variable choice has been declared as well. Assume further that the user has just been presented with the following menu: S: hangar steak, red potatoes, asparagus T: whole trout, long rice, brussel sprouts B: cheddar cheeseburger, steak fries, cole slaw (Yes, this menu really IS a menu!) Write some code that reads a single character (S or T or B) into...
Python 1.)Assume that name is a variable of type String that has been assigned a value....
Python 1.)Assume that name is a variable of type String that has been assigned a value. Write an expression whose value is the last character of the value of name. So if the value of name were "Blair" the expression's value would be 'r'. 2.)Assume that word is a variable of type String that has been assigned a value. Write an expression whose value is a String consisting of the last three characters of the value of word. So if...
. Assume that a double variable named alpha contains the value of an angle in radians....
. Assume that a double variable named alpha contains the value of an angle in radians. Compose a C++ statement that will display the sine of the angle so that it occupies 12 positions on the screen and displays 3 digits after the decimal point.
1) When a service has been performed but no cash has been received, which of the...
1) When a service has been performed but no cash has been received, which of the following statements is true? Select one: a. No journal entry is made. b. The entry includes a debit to Accounts payable. c. The entry includes a credit to Unearned revenue. d. The entry includes a debit to Accounts receivable. 2) Adjusting entries are: Select one: a. not necessary if the accounting system is operating properly. b. usually required before financial statements are prepared. c....
Assume that the following variables have been declared: String a = “Ready, Set, Go!”; String b...
Assume that the following variables have been declared: String a = “Ready, Set, Go!”; String b = a.substring(5, 10); char b1 = b.charAt(2); Evaluate the following expression: 1. Character.isLowerCase(b1) 2. b1 + 5 3. b + 5 4. Character.toLowerCase(b1) 5. a.charAt(2 + a.indexOf(“e”))
a. Assume that x is a variable that has been given a string value. Write an expression whose value is True if and only if x is an octal (Base 8) digits (0-7)
In Python: 1 line short expressionsa. Assume that x is a variable that has been given a string value. Write an expression whose value is True if and only if x is an octal (Base 8) digits (0-7)b. Assume that x is a variable that has been given a string value. Write an expression whose value is True if and only if x is an letter.c. Assume that x is a variable that has been given a string value. Write...
Hosts A and B are communicating over a TCP connection and Host B has already received...
Hosts A and B are communicating over a TCP connection and Host B has already received from A all bytes up through byte 126. Suppose Host A then sends two segments to Host B back-to-back (See the figure below). The first and second segments contain 80 and 40 bytes of data respectively. In the first segment, the sequence number is 127, the source port number is 302, and the destination port number is 80. Host B sends an acknowledgment whenever...
Hosts A and B are communicating over a TCP connection, and Host B has already received...
Hosts A and B are communicating over a TCP connection, and Host B has already received from A all bytes up through byte 126. Suppose Host A then sends two segments to Host B back-to-back. The first and second segments contain 80 and 40 bytes of data, respectively. In the first segment, the sequence number is 127, the source port number is 302, and the destination port number is 80. Host B sends an acknowledgment whenever it receives a segment...
assume a company incurs 100,000 for total variable costs and 150000 for total fixed costs to...
assume a company incurs 100,000 for total variable costs and 150000 for total fixed costs to produce 10000 units. what would the total cost be to produce 12000 units?
a) Given a variable word that has been assigned a string value,write a string expression...
a) Given a variable word that has been assigned a string value, write a string expression that parenthesizes the value of word. So, if word contains "sadly", the value of the expression would be the string "(sadly)"b) Assume that price is an integer variable whose value is the price (in US currency) in cents of an item. Write a statement that prints the value of price in the form "X dollars and Y cents" on a line by itself. So,...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT