Respuesta :
Answer:
Here is code in Java.
import java.util.*;
class Main
{
//main method of the class
public static void main (String[] args) throws java.lang.Exception
{
try{
//declare variables
double base_fee=10,tot_charge;
int no_check;
//scanner object to read the input
Scanner x=new Scanner(System.in);
System.out.println("Enter checks for the month:");
// read number of checks from user
no_check=x.nextInt();
// checks must be positive
while(no_check<0)
{
System.out.println("checks must be positive:");
no_check=x.nextInt();
}
//calculate service charge if checks is less than 20
if(no_check<20)
{
tot_charge=base_fee+(0.10*no_check);
System.out.println("the bank’s service fees for the month :"+tot_charge);
}
//calculate service charge for each for 20–39 checks
else if(no_check>=20&& no_check<40)
{
tot_charge=base_fee+(0.08*no_check);
System.out.println("the bank’s service fees for the month :"+tot_charge);
}
//calculate service charge for each for 40–59 checks
else if(no_check>=40&& no_check<60)
{
tot_charge=base_fee+(0.06*no_check);
System.out.println("the bank’s service fees for the month :"+tot_charge);
}
//calculate service charge for each for checks greater or equal 60
else if(no_check>=60)
{
tot_charge=base_fee+(0.04*no_check);
System.out.println("the bank’s service fees for the month :"+tot_charge);
}
}catch(Exception ex){
return;}
}
}
Explanation:
Create scanner class object to read number of checks from user.If check is less than 0 then it will again ask user to enter the number of checks. Then it will calculate the service charge of that month according to number of checks given by user.
Output:
Enter checks for the month:
-2
checks must be positive:
30
the bank’s service fees for the month :12.4