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

how https://sakaiwashjeff.edu 1x eff.edu/access/content/attachment/15765-CIS-220

ID: 669173 • Letter: H

Question

how https://sakaiwashjeff.edu 1x eff.edu/access/content/attachment/15765-CIS-220-01-2015FAL/Assignments/f16fae1d-926a-4917-a1f3-929 5. Add a prompt asking the user for the diameter of the cheesecake in inches. Permit the user to include partial inches, as shown in the sample output below. Assuming all cheesecakes are two inches thick and knowing that the volume of a cylinder is 3·14 × radius radius x height report back to the user the number of cubic inches of cheesecake that the workers will be sharing. How many people will be in the office? What type of cheesecake will be delivered? chocolate How nany slioes will the chocolate cheesecake be out into? 10 There will be 7 workers sharing 10 slices of chocolate cheesecake. Each worker can have 1 alices of cheesecake with 3 pieces leftover What is the dianeter of the chocolate cheesecake, in inches? 8.5 The workers will be sharing 113.4325 cubic inches of cheesecake Add to your program so that you also tell the user the amount of cubic inches of cheesecake that each worker will eat, if they eat the entirety of the slices allocated to them An example is given in the sample output below 6. How nany people will be in the office? What type of cheesecake will be delivered? pumpkin swirl How nany alices w w many alices will the pumpkin swirl cheesecake be cut into? 12 There wi1l be 4 workera sharing 12 slices of punpkin swirl cheesecake. Each worker can have 3 alices or cheesecake with 0 pieces i rker can have 3 slices of cheesecake with 0 pieces leftover. What is the diameter of the pumpkin swirl cheesecake, in inches? 6.25 The workers will be sharing 61.328125 eubia inches of cheesacake Each worker can eat 15.33203125 cubia inches of chee secake. Gateway

Explanation / Answer

6)

import java.util.Scanner;


public class StringAppend {

   static int HEIGHT = 2; //Given cake is 2 inches in the problem
   public static void main(String[] args) throws Exception{

       Scanner sc = new Scanner(System.in);
       System.out.println("How many people in the office?");
       int np = sc.nextInt();

       System.out.println("What type of cheesecake to be delivered?");
       String cake = sc.next();
      
       System.out.println("How many slices will the chocolate cheesecake be cut into? ");
       int slices = sc.nextInt();
      
       System.out.println("There will be "+np+" workers sharing "+slices+" slices of chocolate cheesecake");
      
       int share = slices/np;
       int rem = slices % np;
       System.out.println("Each woker can have "+share+" slices of cheesecake with "+rem+" pieces leftover");

       System.out.println(" What is the diameter of the chocolate cheesecake (in inches) ?");
       double d = sc.nextFloat();
       double rad = d/2;
      
       double volume = 3.14 * rad * rad * StringAppend.HEIGHT;

       System.out.println("The workers will be sharing "+volume+ " cubic inches of cheesecake");
       System.out.println("Each worker can eat "+ (double)(volume/np)+ " cubic inches of cheesecake" );
      
   }
}

5)


import java.util.Scanner;


public class StringAppend {

    static int HEIGHT = 2; //Given cake is 2 inches in the problem
    public static void main(String[] args) throws Exception{

        Scanner sc = new Scanner(System.in);
        System.out.println("How many people in the office?");
        int np = sc.nextInt();

        System.out.println("What type of cheesecake to be delivered?");
        String cake = sc.next();
       
        System.out.println("How many slices will the chocolate cheesecake be cut into? ");
        int slices = sc.nextInt();
       
        System.out.println("There will be "+np+" workers sharing "+slices+" slices of chocolate cheesecake");
       
        int share = slices/np;
        int rem = slices % np;
        System.out.println("Each woker can have "+share+" slices of cheesecake with "+rem+" pieces leftover");

        System.out.println(" What is the diameter of the chocolate cheesecake (in inches) ?");
        double d = sc.nextFloat();
        double rad = d/2;
       
        double volume = 3.14 * rad * rad * StringAppend.HEIGHT;

        System.out.println("The workers will be sharing "+volume+ " cubic inches of cheesecake");
       // System.out.println("Each worker can eat "+ (double)(volume/np)+ " cubic inches of cheesecake" );
       
    }
}