0% found this document useful (0 votes)
16 views2 pages

PDF Create Task

Uploaded by

rockinandbonkin
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views2 pages

PDF Create Task

Uploaded by

rockinandbonkin
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

4/9/25, 8:12 PM bakerfranke.github.

io/codePrint/

1 //For the weighted classes var = 0 non weighted


2 var totalGPA = 0;
3 var amountneeded;
4 var grade1;
5 var name1;
6 var grade2;
7 var name2;
8 var grade3;
9 var name3;
10 var grade4;
11 var name4;
12 var grade5;
13 var name5;
14 var grade6;
15 var name6;
16 var gpa;
17 //With the weight var = 1 means that it is weighted
18 onEvent("button11", "click", function( ) {
19 setScreen("CalculatorScreen");
20 });
21 onEvent("directions", "click", function( ) {
22 setScreen("dscreen");
23 });
24 onEvent("gobackbutton", "click", function( ) {
25 setScreen("CalculatorScreen");
26 });
27 onEvent("calculatebutton", "click", function( ) {
28 setText("GPAResult", roundToHundreth(calculateGPA()));
29 });
30 onEvent("button1", "click", function( ) {
31 setText("GPAResult", roundToHundreth(calculateGPA()));
32 });
33 //All the OnEvents above help you navigate through the app
34 function roundToHundreth(num) {
35 var tempNum = num * 100;
36 tempNum = Math.round(tempNum);
37 return tempNum/100;
38 //roundtoHundreth function gets the total GPA and makes it have only 1 decimal points
39 //This function prevents a lot of decimals at the end of the GPA total making it simple for the user
40 }
41 //My partner wrote this function
42 function calculateGPA() {
43 totalGPA = 0;
44 for (var i = 1; i < 7; i++) {
45 var tempName = "grade" + i;
46 var weightBoxName = "weightBox" + i;
47 if (getChecked(weightBoxName)) {
48 totalGPA = totalGPA + 1;
49 }
50 if (getText(tempName) == "A") {
51 totalGPA = totalGPA + 4;
52 } else if (getText(tempName) == "B") {
53 totalGPA = totalGPA + 3;

https://bakerfranke.github.io/codePrint/ 1/2
4/9/25, 8:12 PM bakerfranke.github.io/codePrint/
54 } else if (getText(tempName) == "C") {
55 totalGPA = totalGPA + 2;
56 } else if (getText(tempName) == "D"){
57 totalGPA = totalGPA + 1;
58 }
59 }
60 return totalGPA/6;
61 //Gets the total of all classes and divides to get the average
62 }
63 //My partner wrote this function
64 onEvent("calculatebutton", "click", function( ) {
65 roundToHundreth(gradeconsole());
66 });
67 function gradeconsole() {
68 name1 = getText("name1");
69 grade1 = getText("grade1");
70 console.log(((("Your grade is" + " ") + grade1) +" " + "in the class" + " ") + name1);
71 name2 = getText("name2");
72 grade2 = getText("grade2");
73 console.log(((("Your grade is" + " ") + grade2) +" " + "in the class" + " ") + name2);
74 name3 = getText("name3");
75 grade3 = getText("grade3");
76 console.log(((("Your grade is" + " ") + grade3) +" " + "in the class" + " ") + name3);
77 name4 = getText("name4");
78 grade4 = getText("grade4");
79 console.log(((("Your grade is" + " ") + grade4) +" " + "in the class" + " ") + name4);
80 name5 = getText("name5");
81 grade5 = getText("grade5");
82 console.log(((("Your grade is" + " ") + grade5) +" " + "in the class" + " ") + name5);
83 name6 = getText("name6");
84 grade6 = getText("grade6");
85 console.log(((("Your grade is" + " ") + grade6) +" " + "in the class" + " ") + name6);
86 //The code above gets the grade from all your classes then stores it
87 gpa = getText("GPAResult");
88 console.log("Your GPA is" + " " + gpa
89 );
90 //The two lines above will display your GPA
91 if (getText("GPAResult") < 4) {
92 amountneeded = 4 - getText("GPAResult");
93 console.log("You need" + " " + amountneeded + " "+ "points to get a 4 GPA");
94 } else if ((getText("GPAResult") ==4)) {
95 console.log("You have a" + " " + gpa + " " + "GPA");
96 } else if ((getText("GPAResult") > 4)) {
97 console.log("You have" + " " + gpa + " "+ "which means your GPA is amazing!");
98 }
99 //The if statement above will use your GPA to determine if you have a 4.0 or above
100 //Then if it is below that then it will tell you what you need to get to a 4.0
101 }
102 //Me and my partner wrote this function
103 //

PDF document made with CodePrint using Prism

https://bakerfranke.github.io/codePrint/ 2/2

You might also like