Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

egg Study Guided S /pid-769277-dt-content-rid-8558821_1/courses/Csci 111 HERATH

ID: 3730240 • Letter: E

Question

egg Study Guided S /pid-769277-dt-content-rid-8558821_1/courses/Csci 111 HERATH ALL 2017-2018 SPRG/CSCI962 Problem Description: Use the Java techniques to write an application program for the following A bank charges a standard base fee of $10 per month, plus the following check fees for a commercial checking account. Number of checks Less than 20 checks 20-39 checks 40-59 checks 60 or more checks Cost (in S) for each check 0.10 0.08 0.06 0.04 Write a program that prompts the user to enter the number of checks written for the month. The program should then calculate and display the bank's service fees for the month. If the number of checks is less than 0, display a message an error input has been entered." This will then exit your program. Example output: Enter the number of checks: 10 The bank's service feo for 10 checks is 11.00 dollars. Enter the number of checks: 39 The bank's service fee for 39 checks is 13.12 dollars. Enter the number of checks: 45 The bank's service fee for 45 checks is 12.70 dollars. Enter the number of checks: 62 The bank's service fee for 62 checks is 12.48 do1lars. Enter the number of checks: -12 An ERROR input has been entered.

Explanation / Answer

CalculateServiceFee.java

import java.util.Scanner;

public class CalculateServiceFee {

public static void main(String[] args) {

//Declaring variables

int noOfChecks;

double baseFee=10,totServiceFee=0.0;

/*

* Creating an Scanner class object which is used to get the inputs

* entered by the user

*/

Scanner sc = new Scanner(System.in);

//Getting the input entered by the user

System.out.print("Enter the number of Checks :");

noOfChecks=sc.nextInt();

  

// if the no of checks is less than zero displaying error message

if(noOfChecks<0)

{

System.out.println("An Error Input has been entered.");

}

else

{

//Based on the number of checks claculating the service charge

if(noOfChecks<20)

{

totServiceFee=baseFee+noOfChecks*0.10;

}

else if(noOfChecks>=20 && noOfChecks<39)

{

totServiceFee=baseFee+noOfChecks*0.08;

}

else if(noOfChecks>=40 && noOfChecks<49)

{

totServiceFee=baseFee+noOfChecks*0.06;

}

else if(noOfChecks>=60)

{

totServiceFee=baseFee+noOfChecks*0.04;

}

}

//Displaying the output

System.out.printf("The bank's service fee for %d checks is %.2f dollars.",noOfChecks,totServiceFee);

}

}

______________________

Output:

Enter the number of Checks :10
The bank's service fee for 10 checks is 11.00 dollars.

______________________

Output#2:

Enter the number of Checks :45
The bank's service fee for 45 checks is 12.70 dollars.

______________________

Output#3:

Enter the number of Checks :62
The bank's service fee for 62 checks is 12.48 dollars.

_______________________

Output#4:

Enter the number of Checks :-12
An Error Input has been entered.

__________________Thank You