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

Part A) A bank charges $8 per month plus the following fees: The program should

ID: 3731805 • Letter: P

Question

Part A) A bank charges $8 per month plus the following fees:

The program should ask the user for the number of checks and compute and display the total fee.

Part B) Ask for total amount for an online shopping order and calculate the shipping cost based on the following table. Also, calculate the total cost (order amount + shipping cost). Of course, one must also ask for the destination location (within USA or Canada). If the total input order is 0 or less or it is more than $10,000, display an error message and do not perform any calculation. Issue an error message, if the destination is not one of USA or Canada. Make sure to format the amount of shipping cost to 2 digits after the decimal point.

Check fee Number of checks $.09 each Fewer than 20 checks $.07 each 20-39 checks $.06 each 40-59 checks $.05 each 60 or more checks

Explanation / Answer

CalculateServiceFee.java

import java.util.Scanner;

public class CalculateServiceFee {

public static void main(String[] args) {

// Declaring variables

int noOfChecks;

double baseFee = 8, 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.09;

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

totServiceFee = baseFee + noOfChecks * 0.07;

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

totServiceFee = baseFee + noOfChecks * 0.06;

} else if (noOfChecks >= 60) {

totServiceFee = baseFee + noOfChecks * 0.05;

}

}

// 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 :40
The bank's service fee for 40 checks is 10.40 dollars.

___________________

2)

CalShippingCost.java

import java.util.Scanner;

public class CalShippingCost {

public static void main(String[] args) {

//Declaring variables

double orderAmt,shippingCost = 0,totCost;

String dest;

/*

* 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 total Input oder :$");

orderAmt =sc.nextDouble();

if(orderAmt<=0 || orderAmt>10000)

{

System.out.print("Invalid.Must be greater than Zero.");

  

}

else

{

System.out.print("Enter Destination :");

dest=sc.next();

if(!dest.equalsIgnoreCase("USA") && !dest.equalsIgnoreCase("CANADA"))

{

System.out.println("No Delivery for "+dest);

}

else

{

if(dest.equalsIgnoreCase("USA"))

{

if(orderAmt>=0 && orderAmt<50)

{

shippingCost=6;

}

else if(orderAmt>=50 && orderAmt<100)

{

shippingCost=9;

}

else if(orderAmt>=100 && orderAmt<150)

{

shippingCost=12;

}

else if(orderAmt>=150)

{

shippingCost=0;

}

}

else if(dest.equalsIgnoreCase("CANADA"))

{

if(orderAmt>=0 && orderAmt<50)

{

shippingCost=8;

}

else if(orderAmt>=50 && orderAmt<100)

{

shippingCost=12;

}

else if(orderAmt>=100 && orderAmt<150)

{

shippingCost=15;

}

else if(orderAmt>=150)

{

shippingCost=0;

}

}

totCost=orderAmt+shippingCost;

System.out.printf("Order Amount : $%.2f ",orderAmt);

System.out.printf("Shipping Cost : $%.2f ",shippingCost);

System.out.println("------------------");

System.out.printf("Total Amount : $%.2f ",totCost);

System.out.println("------------------");

}

}

  

}

}

___________________

Output#1:

Enter the total Input oder :$-50
Invalid.Must be greater than Zero.

__________________

Output#2:

Enter the total Input oder :$100
Enter Destination :India
No Delivery for India

__________________

Output#3:

Enter the total Input oder :$100
Enter Destination :Usa
Order Amount : $100.00
Shipping Cost : $12.00
------------------
Total Amount : $112.00
------------------

___________________Thank You