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

PART 1 OBJECTIVES -continue to practice to write the code for the data type clas

ID: 3709063 • Letter: P

Question

PART 1 OBJECTIVES -continue to practice to write the code for the data type class that includes data member list, constructor, mutator method, accessor methods, method toString for output -Understand relationship between the data type class and the controlling class The following class is used for quesiton 1, 2, 3, 4: data type class Item and driver class MyDriverClass public class Product public class TheDriverClass / A? private String naneProduct; private double priceUnit; private static int count 0; public static void nain (String 1 args) //rite the code to call the static method reduceCount //?? public Product) //rite the code to cal1 the no-argument constructor TheDriverClass aProduct//I //rite the code to call the paraneter //constructor to pass the product name as // ceCook Topu ?nd the unit price is $399.49 //to the object //?? Public Product(String name, double price) System.out.println DefaultItem// K? anItem); I L priceUnit Price; //call the method aProduct //?? public static void reduceCount ) I E 2 public void setNaneIten (String nane) nameProduct nane; F 2 public double getPriceUnit) return priceUnit; public String toString) "nUnit PricepriceUnit; public void aMethod) System.out-println("Display the nessage)

Explanation / Answer

Part 1:

Question 1:

A. class variables

B. default constructor

C. argument constructor

D. static method

E. mutator

F. accessor

G. override method

Question 2:

H. Product.reduceCount();

Question 3:

I. Product aProduct = new Product();

J. Product aotherProduct = new Product("Cook Top",399.49);

Question 4:

K. Product =

Unit Price = 0.0

L.

Product = Cook Top

Unit Price = 399.49

M.

System.out.println(aProduct);

Part 2:

public static double SP2018LAB7_PART2_Add_YourLastname(int number1,double number2)
{
  return number1+number2;
}
public static double SP2018LAB7_PART2_Add_YourLastname(double number1,double number2)
{
  return number1+number2;
}
public static String SP2018LAB7_PART2_Add_YourLastname(String s1,String s2)
{
  return s1+" "+s2;
}

Part 3:

import java.util.Scanner;

class SP2018LAB7_staticShapes_yourLastname
{
public static double rectangle(double length,double width)
{
return length*width;
}
public static double square(double side)
{
return side*side;
}
public static double circle(double radius)
{
return 3.14*radius*radius;
}
public static double triangle(double base,double height)
{
return 0.5*base*height;
}
public static double trapezoid(double a,double b,double h)
{
return (a+b)*h/2;
}
public static double rhombus(double p,double q)
{
return p*q/2;
}
public static double kite(double p,double q)
{
return p*q/2;
}
public static double parallelogram(double b,double h)
{
return b*h;
}

}
class SP2018LAB7_CarpetInstallation_yourLastName
{
public static void main (String[] args)
{
double totalArea = 0.0;
int option = 10;
double side,length,width,a,b,h,base,height,radius;
Scanner input = new Scanner(System.in);
System.out.println("ART CARPET COMPANY");
System.out.println("the quote of the project - 123,Walnut Road, Dallas- TX 75423");
System.out.println("CARPET INSTALLATION");

do
{
System.out.println("1. Square");
System.out.println("2. Rectangle");
System.out.println("3. Triangle");
System.out.println("4. Circle");
System.out.println("5. Trapezoid");
System.out.println("6. Rhombus");
System.out.println("7. Kite");
System.out.println("8. Paralellogram");
System.out.println("9. Done");

System.out.println("Enter the option : ");
option = input.nextInt();
if(option == 9)
break;
switch(option)
{
case 1:
   System.out.println("Enter the side of square :");
   side = input.nextDouble();
   System.out.println("SQUARE - SIDE ="+side+"           "+SP2018LAB7_staticShapes_yourLastname.square(side));
   totalArea += SP2018LAB7_staticShapes_yourLastname.square(side);
   break;
case 2:
   System.out.println("Enter the length and width of rectangle :");
   length = input.nextDouble();
   width = input.nextDouble();
   System.out.println("RECTANGLE - LENGTH ="+length+" WIDTH = "+width+"           "+SP2018LAB7_staticShapes_yourLastname.rectangle(length,width));
   totalArea += SP2018LAB7_staticShapes_yourLastname.rectangle(length,width);
   break;
case 3:
   System.out.println("Enter the base and height of triangle :");
   base = input.nextDouble();
   height = input.nextDouble();
   System.out.println("TRIANGLE - BASE "+base+"HEIGHT"+height+"           "+SP2018LAB7_staticShapes_yourLastname.triangle(base,height));
   totalArea += SP2018LAB7_staticShapes_yourLastname.triangle(base,height);
   break;
case 4:
   System.out.println("Enter the radius of circle :");
   radius = input.nextDouble();
   System.out.println("CIRCLE _ RADIUS "+radius+"           "+SP2018LAB7_staticShapes_yourLastname.circle(radius));
   totalArea += SP2018LAB7_staticShapes_yourLastname.circle(radius);
   break;

case 5:
   System.out.println("Enter a,b and height of trapezoid :");
   a = input.nextDouble();
   b = input.nextDouble();
   h = input.nextDouble();
   System.out.println("TRAPEZOID - a-"+ a+" b="+b+" h="+h+"           "+SP2018LAB7_staticShapes_yourLastname.trapezoid(a,b,h));
   totalArea += SP2018LAB7_staticShapes_yourLastname.trapezoid(a,b,h);
   break;
case 6:
   System.out.println("Enter the length and width of rhombus :");
   length = input.nextDouble();
   width = input.nextDouble();
   System.out.println("RHOMBUS - LENGTH ="+length+" WIDTH = "+width+"           "+SP2018LAB7_staticShapes_yourLastname.rhombus(length,width));
   totalArea += SP2018LAB7_staticShapes_yourLastname.rhombus(length,width);
   break;
case 7:
   System.out.println("Enter the length and width of kite :");
   length = input.nextDouble();
   width = input.nextDouble();
   System.out.println("KITE - LENGTH ="+length+" WIDTH = "+width+"           "+SP2018LAB7_staticShapes_yourLastname.kite(length,width));
   totalArea +=SP2018LAB7_staticShapes_yourLastname.kite(length,width);
   break;
case 8:
   System.out.println("Enter the length and width of parallelogram :");
   length = input.nextDouble();
   width = input.nextDouble();
   System.out.println("PARALLELOGRAM - LENGTH ="+length+" WIDTH = "+width+"           "+SP2018LAB7_staticShapes_yourLastname.parallelogram(length,width));
   totalArea +=SP2018LAB7_staticShapes_yourLastname.parallelogram(length,width);
   break;
default:

   break;
}
}while(option != 9);

System.out.printf("Total Area :                      %.2f",totalArea);
System.out.printf(" Carpet cost ($2.5 per square feet        %.2f", 2.5*totalArea);
System.out.printf(" Labor ($60 per 50 square feet        %.2f", 60*totalArea/50);
double subTotal = 2.5*totalArea+60*totalArea/50;
System.out.printf(" SubTotal    %.2f",subTotal);
System.out.printf(" Tax (8.25%)   %.2f",subTotal*0.0825);
System.out.printf(" Total          %.2f",subTotal*(1+0.0825));
}


}

Output:

ART CARPET COMPANY
the quote of the project - 123,Walnut Road, Dallas- TX 75423
CARPET INSTALLATION
1. Square
2. Rectangle
3. Triangle
4. Circle
5. Trapezoid
6. Rhombus
7. Kite
8. Paralellogram
9. Done
Enter the option :
Enter the length and width of rectangle :
RECTANGLE - LENGTH =20.56 WIDTH = 8.42           173.1152
1. Square
2. Rectangle
3. Triangle
4. Circle
5. Trapezoid
6. Rhombus
7. Kite
8. Paralellogram
9. Done
Enter the option :
Enter the side of square :
SQUARE - SIDE =12.5           156.25
1. Square
2. Rectangle
3. Triangle
4. Circle
5. Trapezoid
6. Rhombus
7. Kite
8. Paralellogram
9. Done
Enter the option :
Enter the base and height of triangle :
TRIANGLE - BASE 4.6HEIGHT2.3           5.289999999999999
1. Square
2. Rectangle
3. Triangle
4. Circle
5. Trapezoid
6. Rhombus
7. Kite
8. Paralellogram
9. Done
Enter the option :
Enter the radius of circle :
CIRCLE _ RADIUS 3.4           36.2984
1. Square
2. Rectangle
3. Triangle
4. Circle
5. Trapezoid
6. Rhombus
7. Kite
8. Paralellogram
9. Done
Enter the option :
Total Area :                      370.95

Carpet cost ($2.5 per square feet        927.38

Labor ($60 per 50 square feet        445.14

SubTotal    1372.53

Total    1485.84

Do ask if any doubt. Please upvote