We would like to assess a service charge for cashing a check. The service charge depends on the amount of the check. If the check amount is less than $10, we will charge $1. If the amount is greater than $10 but less than $100, we will charge 10% of the amount. If the amount is greater than $100, but less than $1,000, we will charge $5 plus 5% of the amount. If the value is over $1,000, we will charge $40 plus 1% of the amount. Use a multibranch if-else statement in a fragment of code to compute the service charge.

What will be an ideal response?


```
if(amount < 10.0)
serviceCharge = 1.0;
else if(amount < 100.0)
serviceCharge = 0.1 * amount;
else if(amount < 1000.0)
serviceCharge = 5.0 + 0.05 * amount;
else
serviceCharge = 40.0 + 0.01 * amount;
```

This code is in Fragments.java.

Computer Science & Information Technology

You might also like to view...

Assume class Book has been declared. Which set of statements creates an array of Books?

a. Book[] books; books = new Book[numberElements]; b. Book[] books]; books = new Book()[numberElements]; c. new Book() books[]; books = new Book[numberElements]; d. All of the above.

Computer Science & Information Technology

When setting a screen saver, a reasonable amount of time for most users would be ________

A) 60 seconds B) 120 minutes C) 10 minutes D) 1 minute

Computer Science & Information Technology

You can create and use a(n) ____________________ to speed up the searching process significantly.

Fill in the blank(s) with the appropriate word(s).

Computer Science & Information Technology

A temporary storage area for text or graphics that you select and then cut or copy

What will be an ideal response?

Computer Science & Information Technology