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

For this assignment, you will develop Java programs to solve several problems. Y

ID: 3543084 • Letter: F

Question

For this assignment, you will develop Java programs to solve several problems. You will also write test cases with which to test those programs.

It is very important that you spell and capitalize the names of the programs exactly as they are given in this assignment. It is also very important that you submit your test cases as a plain-text file.

You will need the IO module to read input from the keyboard and to generate output in a form that our grading program can understand. Do not modify or hand in the IO module. The "RESULT:" that precedes the output is automatically generated by the IO module. See the big text below:



Before you begin, read the document How-To-Use-The-IO-Module-In-Programming-Assignments.html.

If you know some Java already, you may use advanced features that we have not covered in class yet (though it is not necessary to do so). However, you may NOT use any modules or classes from outside java.lang (do not add any "import" statements to your programs).

For this assignment, when you detect an error condition, call IO.reportBadInput() and halt the program.

Warm Up:

Write your code in a file called Warmup.java. Use the IO module to read inputs.

Ask for 2 numbers (integers) from the user. Print out the sum and the average (mean) of the two numbers.

Example:

Enter number: 3
Enter number: 5

Write your code in the file ShippingCosts.java. Write your test cases in assign2-testcases.txt.

Suppose that there is a website Quarter.com where you can buy used items (at up to half price!).  The Standard Delivery shipping and handling charge is $3.99 per shipment (not per item) plus $0.99 per pound of the shipment. Customers may choose Superfast Delivery instead, for $12.99 per shipment (not per item) plus $4.99 per pound of the shipment. The website is running a promotion whereby customers receive free Standard Delivery shipping if they buy more than 10 items.

Ask the user for the number of items they wish to buy (integer) and whether they want Superfast Delivery (boolean: true means Superfast, false means Standard), and then the total weight of the shipment in that order. Then compute the total cost of their order (real number).

Example:

Write your code in the file PayFriend.java. Write your test cases in assign2-testcases.txt.

You work for the a payment processing service called PayFriend. PayFriend charges money receivers the following fees

For example, an payment of $40,000 would be subject to $950 fee: 1% on the first $10,000 ($100 fee), 2% on the next $5,000 ($100 fee), and 3% on the last $25,000 ($750 tax).

Ask the user for their payment amount (integer) and compute the amount of the fee that they owe (real number).

Example:

Write your code in the file Party.java. Write your test cases in assign2-testcases.txt.

Suppose that you are responsible for buying pizza and soda for your employer's annual company party. You must buy entire pizza pies and cases of soda (boxes of soda cans). You cannot buy individual slices of pizza or cans of soda, nor can you buy fractional numbers of pizza pies or soda cases.

Ask the user for the following information, in this order:

Compute the total cost of the pizza and soda you will need to buy. Do not buy more than you need to in order to supply each partygoer with the desired number of pizza slices and soda cans.

For this problem only, you may assume that the user will only enter positive numbers (you do not need to check for this).

Example:

Explanation of example: We need 300 slices of pizza and 200 cans of soda. Since there are 8 slices in a pie and 72 cans in a case, we need to buy at least 38 pies and 3 cases.

Explanation / Answer

############# Warmup.java###########


import java.util.Scanner;


public class Warmup

{

public static void main(String args[])

{

System.out.println("Enter the first integer");

Scanner in=new Scanner(System.in);

int int1=in.nextInt();

System.out.println("Please enter the second integer");

int int2=in.nextInt();

int sum=int1+int2;

double average=(double)sum/2 ;

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

System.out.println("Sum of entered number is="+sum+" Average of entered number is= "+average);

}

}


--------------------------------------------------------------------------------------------------------------------------------

##################ShippingCosts.java#######################


import java.util.Scanner;


public class ShippingCosts

{

public static void main(String args[])

{

Scanner in=new Scanner(System.in);

double cost=0.0;

System.out.println("Do you want superfast delivery type yes or no");

String type=in.nextLine();

System.out.println("Please enter the number of item you want to purchase");

  

  

int nitem=in.nextInt();

  

System.out.println("Enter the weight of the shipment");

double weight=in.nextDouble();

if(type.equals("yes"))

{

cost=12.99+4.99*weight;

}

else

{

if(nitem>10)

{

cost=0.0;

}

else

{

cost=3.99+0.99*weight;

}

}

System.out.println("Shipment Cost:"+cost);

}

  

}

----------------------------------------------------------------------------------------------------------

#################### PayFriend.java #######################


import java.util.Scanner;


public class PayFriend {

public static void main(String args[])

{

double fee=0.0;

Scanner in=new Scanner(System.in);

System.out.println("Please enter the amount");

double amount=in.nextDouble();

if(amount<=100)

{

fee=5.0;

}

else if(amount>100 && amount<=1000)

{

double t=amount*0.03;

if(t>6)fee=t;

else fee=6.0;   

}

else if(amount>1000 && amount<=10000)

{

double t=amount*0.01;

if(t>6)fee=t;

else fee=15.0;   

}

else if(amount>10000)

{

if(amount>15000)

{

fee=10000*0.01+5000*0.02+(amount-15000)*0.03;

}

else

{

fee =10000*0.01+(amount-10000)*0.02;

}

}

System.out.println("total fee="+fee);

}

  

}

------------------------------------------------------------------------------------------------------------

###################### Party.java #################


import java.util.Scanner;


public class Party

{

public static void main(String args[])

{

Scanner in=new Scanner(System.in);

System.out.println("Enter the number of people attending the party");

int people=in.nextInt();

System.out.println("Enter the number of slices of pizza each person should be able to eat");

int canEat=in.nextInt();

System.out.println("Enter the number of cans of soda each person should be able to drink");

int canDrink=in.nextInt();

System.out.println("Enter the cost of a pizza pie");

double pizzaCost=in.nextDouble();

System.out.println("Enter the number of slices in a pizza pie");

int slices=in.nextInt();

System.out.println("Enter the cost of a case of soda");

double sodaCost=in.nextDouble();

System.out.println("Enter the number of cans in a case of soda");

int cases=in.nextInt();

int tslices=people*canEat;

int tcans=people*canDrink;

int x=tslices/slices;

int y=tcans/cases;

if(tslices%slices != 0)x=x+1;

if(tcans%cases !=0)y=y+1;

double total=x*pizzaCost+y*sodaCost;

System.out.println("total amount:="+total);

  

  

}

}

----------------------------------------------------------------------------------

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote