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

Write, test and document (internally) a Java program to solve the following prob

ID: 3624185 • Letter: W

Question

Write, test and document (internally) a Java program to solve the following problem:
A local company has the following monthly charges for snowclearing services:
$250 for 0 – 5 visits
$250 plus $55 for each visit over 5
13% tax is to be charged in each case
Method of payment is by cheque or credit card. For payment by credit card, an extra 3% (of
the subtotal, i.e., the total before tax) is charged.
Input the following information:
• month name
• customer name and address
• number of visits
• any previous balance
• method of payment (CH – cheque; CC – credit card)
If the previous balance is not zero, interest of 4% of that balance is to be charged.
Calculate and output the total amount due. Also output the month and customer name and
address.

Explanation / Answer

import java.util.*;
import java.io.*;

public class Payment
{
public static void main(String[] args)
{
String name;
String address;
double visits;
double previousBalance;
double paymenttype;

Scanner input = new Scanner(System.in);

System.out.println("Enter name:");
name = input.nextLine();

System.out.println("Enter address:");
address = input.nextLine();

System.out.println("Enter number of times visits:");
visits = input.nextDouble();

System.out.println("Enter any previous balance:");
previousBalance = input.nextDouble();

System.out.println("Enter payment by cheque or credit card : 1. credit card   2.cheque:");
paymenttype = input.nextDouble();

double totalpreviousBalance = (previousBalance * 0.4);

if(visits <= 5)
{

if(paymenttype == 1)  
{
double total = (250 + (250 * 0.13));
System.out.println("Name" + name + " Address " +address + " Total amount is $ " +(total + (total * 0.3) +totalpreviousBalance) ) ;
}

else if(paymenttype == 2)  
{
double total = (250 + (250 * 0.13)+totalpreviousBalance);
System.out.println("Name" + name + " Address " +address +" Total amount is $" + total ) ;
}


}


else if(visits > 5)
{

double visitstimes = (visits - 5);

if(paymenttype == 1)  
{
double total = (250 + (250 * 0.13)+(visitstimes * 55));
System.out.println("Name" + name + " Address " +address +" Total amount is $ " +(total + (total * 0.3)+totalpreviousBalance) ) ;
}

else if(paymenttype == 2)  
{
double total = (250 + (250 * 0.13)+(visitstimes * 55)+totalpreviousBalance);
System.out.println("Name" + name + " Address " +address +" Total amount is $" + total ) ;
}

}