-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProj1.java
More file actions
89 lines (62 loc) · 2.68 KB
/
Copy pathProj1.java
File metadata and controls
89 lines (62 loc) · 2.68 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/*
* <Proj1>
* <Samuel Seidl / Thursday 4pm / Atef Khan>
*
* <Program that calcuates the grade in a class and how many pizzas to order and how many leftover slices there will be>
*/
import java.util.*;
public class Proj1 {
public static void main (String[] args){
Scanner s = new Scanner(System.in);
String input;
double project1 ;//Project score #1
double project2;//Project score #2
double project3;//Project score #3
double midterm ;//midterm exam score
double finalExam; //final exam score
final int POINTSPOSSIBLE = 290;
System.out.print("Enter in Project score #1 (0-30): ");
input = s.nextLine();
project1 = Double.parseDouble(input);
System.out.print("Enter in Project score #2 (0-30): ");
input = s.nextLine();
project2 = Double.parseDouble(input);
System.out.print("Enter in Project score #3 (0-30): ");
input = s.nextLine();
project3 = Double.parseDouble(input);
System.out.println("");
System.out.print("Enter the midterm exam score (0-100): " );
input = s.nextLine ();
midterm = Double.parseDouble(input);
System.out.print("Enter the final exam score:(0-100): ");
input = s.nextLine ();
finalExam = Double.parseDouble(input);
String total = String.format("Overall grade percentage: %.2f", ((project1 + project2 + project3 + midterm + finalExam)/POINTSPOSSIBLE) * 100 ) ;
System.out.printf(total);
System.out.println ("%");
System.out.println("");
final int LARGEPIZZA = 20;
final int PERPERSON = 2;
int peopleAmmount;
int leftover;
System.out.print("What is the number of people expected at the pizza party? " );
input = s.nextLine ();
peopleAmmount = Integer.parseInt(input);
System.out.println("");
int sliceAmount = (peopleAmmount * PERPERSON);
if ( sliceAmount == 40) {
String pizzaTotal= String.format ("For " + peopleAmmount + " people, that would be 2 pizza(s) with each having " + PERPERSON + " slices each. There would be 0 slice(s) leftover");
System.out.printf("pizzaTotal");
}
if (sliceAmount < 20) {
leftover = (20 - sliceAmount);
String pizzaTotal = String.format ("For " + peopleAmmount + " people, that would be 1 pizza(s) with each having " + PERPERSON+ " slices each. There would be " + leftover + " slice(s) leftover");
System.out.printf(pizzaTotal);
} else {
leftover = (40 - sliceAmount); // need to declare variable
String pizzaTotal = String.format ("For " + peopleAmmount + " people, that would be 2 pizza(s) with each having " + PERPERSON + " slices each. There would be " + leftover + " slice(s) leftover");
System.out.printf(pizzaTotal);
} //end of else
//end of second if statement
} //end of main
} //end