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

This is in Java. IceStand Class: This class has two properties: name & location

ID: 3919010 • Letter: T

Question

This is in Java.

IceStand Class: This class has two properties: name & location (both are strings). Create the corresponding Mutators (set methods) with this specification: setName: coverts the shaved ice stand name received as parameter to all capital letters, add the words “SHAVED ICE”, & concatenate it with the underline according to the example below. This new string is assigned to the name property. setLocation: based on the zip code received as parameter (a string), assign the city to the location property: 51558 Butonsville, 51555 Dunburton, 51537 Fairmont, Other value FIlmore Constructor: Create only one constructor that receives as parameters the name of the shaved ice stand, & the zip code (string). In this constructor, call the corresponding mutators (setters), so the properties can be set up. toString Method: return a string with the name & location (first three lines of the bill). Snowball Class: This class has the following properties: size (type: string) quantity (type: integer) unitPrice (type: double) totalPrice (type double) In addition, it will have a constant: TAX_RATE (static). CPIT 102 –into programming School of Tech & Art Campus: Fairmont – Department Telephone: 555-555-5555 Project Three Page 2 Constructor: In this case create an empty constructor (all the properties initialized to zero or null). calculatePrice Method: this method will receive the size, quantity, & unit price of the snowball sold as parameters. It will set the size, quantity, & unit price (set up the properties values of the object) & calculate the total price. It will also return the total price calculated. toString Method: will return the string composed by the size, quantity, unit price, & total price. Please format the prices using the currency format. You should create the Format object inside of the method. calculateTax Method: this method will return the value of the tax based on the total sent to it as parameter. This method should be static. With the two classes you created, test them by creating the ShavedIceStand.java demo: The prices for each size are as follow: Small $ 1.25 Medium $ 2.40 Large $ 3.55 You should follow the following steps: • Ask the user for the name of the shave ice stand, & the zip code (remember that this value is a string). • Use the IceStand class to set the name & location values (instantiate an object of this class) • Create a while loop with sentinel value (quantity for small is -1). • Once the user enters the number of small, medium, & large snowballs sold in this transaction, display the title of the bill. • Use the Snowball class to instantiate three objects smallSnowball, mediumSnowball, largeSnowball, & calculate the total for each one of them • Display the detail of the bill, including the subtotal. • Calculate (using the static method) & display the tax for the whole bill. • Calculate & display the total of the bill. In each iteration of the loop: print the title of the bill, the detail, the tax, & the total bill.

Thanks!

Explanation / Answer

public class IceStand {

private String name;

private String location;

public String getName() {

return name;

}

public void setName(String name) {

this.name = name.toUpperCase();

this.name += " SHAVED ICE";

}

public String getLocation() {

return location;

}

public void setLocation(String location) {

switch (location) {

case "51558":

this.location = location + " Butonsville";

break;

case "51555":

this.location = location + " Dunburton";

break;

case "51537":

this.location = location + " Fairmont";

break;

default:

this.location = location + " Fllmore";

break;

}

}

public IceStand(String name, String location){

setName(name);

setLocation(location);

}

@Override

public String toString() {

// TODO Auto-generated method stub

return name+ " " + location +" "+"--------------------------";

}

}

public class SnowBall {

private String size;

private int quantity;

private double unitPrice;

private double totalPrice;

private static int TAX_RATE = 10 ;

//Change the value according to you of tax rate

public SnowBall(){}

public double calculatePrice(String size, int quantity, double unitPrice){

this.size = size;

this.quantity = quantity;

this.unitPrice = unitPrice;

this.totalPrice = quantity*unitPrice;

return totalPrice;

}

public static double calculateTax(double totalPrice){

return totalPrice*TAX_RATE/100;

}

}

import java.util.Scanner;

public class ShavedIceStand {

public static void main(String[] args) {

// TODO Auto-generated method stub

Scanner scn = new Scanner(System.in);

Scanner snum = new Scanner(System.in);

System.out.println("Enter the name :");

String name = scn.nextLine();

System.out.println("Enter the location: ");

String location = scn.nextLine();

IceStand testStand = new IceStand(name,location);

int smallQ = 0 , mediumQ = 0 , largeQ = 0;

while(smallQ!=-1){

System.out.println("No of small quantity");

smallQ = snum.nextInt();

System.out.println("No of medium quantity");

mediumQ = snum.nextInt();

System.out.println("No of large quantity");

largeQ = snum.nextInt();

SnowBall small = new SnowBall();

SnowBall medium = new SnowBall();

SnowBall large = new SnowBall();

double sprice = small.calculatePrice("Small", smallQ, 1.25);

double mprice = medium.calculatePrice("Medium", mediumQ, 2.40);

double lprice = large.calculatePrice("Large", largeQ, 3.55);

double total = sprice+mprice+lprice;

double taxTotal = small.calculateTax(sprice) + medium.calculateTax(mprice) + large.calculateTax(lprice);

System.out.println(testStand);

System.out.println("SmallSnowBall -- "+smallQ + " = " + sprice +

" MediumSnowBall -- "+mediumQ + " = " + mprice +

" LargeSnowBall -- "+largeQ+" = "+ lprice);

System.out.printf(" SubTotal = %.2f ",total );

System.out.printf(" Tax = %.2f ", taxTotal );

// Leaving the tax as tax rate as 10 as is not known

System.out.printf(" Total = %.2f ",sprice+mprice+lprice + taxTotal);

System.out.println("If want to close enter -1");

smallQ = snum.nextInt();

}

}

}

//All The Best

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