-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAssignment1.java
More file actions
47 lines (36 loc) · 1.75 KB
/
Assignment1.java
File metadata and controls
47 lines (36 loc) · 1.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// CSE 110 Spring 2021
// Assignment : 1 "Pizza Party"
// Name : Erik Gotta
// ASU ID : 1222628953
// Total Time : 60 minutes
import java.util.Scanner;
// A class to take user input about a pizza party and give back how the pizza should be divided among guests
class Assignment1
{
public static void main(String args[])
{
Scanner sc = new Scanner(System.in);
//Pizza Input Collection
System.out.print("\nNumber of pizzas purchased : ");
int pizzasPurchased = sc.nextInt();
System.out.print("Number of slices per pizza : ");
int numberSlices = sc.nextInt();
System.out.print("Number of adults : ");
int numberAdults = sc.nextInt();
System.out.print("Number of children : ");
int numberChildren = sc.nextInt();
//Computation of inputs
int totalSlices = numberSlices * pizzasPurchased;
int adultSlices = numberAdults * 2;
int childrenTotalSlices = totalSlices - adultSlices;
int childSlicesRecieved = childrenTotalSlices / numberChildren;
int slicesLeftOver = totalSlices - adultSlices - (childSlicesRecieved * numberChildren);
//Output Statements / Results
System.out.println("\nTotal number of slices of pizza : " + totalSlices);
System.out.println("Total number of slices given to adults : " + adultSlices);
System.out.println("Total number of slices available for children : " + childrenTotalSlices);
System.out.println("Number of slices each child will get : " + childSlicesRecieved);
System.out.println("Number of slices left over : " + slicesLeftOver);
sc.close();
}
}