-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstudyCalculator.js
66 lines (50 loc) · 3.05 KB
/
studyCalculator.js
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
const input = require('readline-sync');
//let choice = input.question("Do you want to choose daily minutes to study or overall goal time period? (please type either 'daily' or 'goal' or 'cancel' to exit) \n");
const options = ['daily', 'goal', 'cancel'];
let notOver = true;
do {
let choice = input.question("Do you want to choose daily minutes to study or overall goal time period? (please type either 'daily' or 'goal' or 'cancel' to exit) \n");
while (!options.includes(choice)) {
choice = input.question("Do you want to choose daily minutes to study or overall goal time period? (please type either 'daily' or 'goal' or 'cancel' to exit) \n");
}
//choice = daily
if (choice == options[0]) {
let studyTopic = input.question("What do you want to study? ");
let timeStudy = input.question("How long will you study daily (in minutes)? ");
let timeInYear = Math.round(365 * Number(timeStudy) / 60 * 100) / 100;
let timeInMonth = Math.round(30 * Number(timeStudy) / 60 * 100) / 100;
let timeInWeek = Math.round(7 * Number(timeStudy) / 60 * 100) / 100;
console.log();
console.log(`\nIf you study ${timeStudy} minutes a day of ${studyTopic},
you will study ${timeInWeek} hours per week
${timeInMonth} hours per month
and ${timeInYear} hours per year.\n\n`);
console.log();
//choice = goal
} else if (choice == options[1]) {
let studyTopic = input.question("What do you want to study? ");
let goalStudy = input.question("How many hours do you want to study? ");
let studyPeriod = input.question("Over how many days do you want to reach this goal? (week = 7, month = 30, year = 365) ");
let calculatedStudyDaily = Math.round((Number(goalStudy) / Number(studyPeriod)) * 60 * 100) / 100;
console.log();
console.log("If you want to study " + goalStudy + " hours of " + studyTopic + " over " + studyPeriod + " days, it will take you " + calculatedStudyDaily + " minutes a day. \n\n");
} else if (choice == options[2]) {
notOver = false;
console.log("Exiting now");
}
} while (notOver);
/*let studyTopic = input.question("What do you want to study? ");
let timeStudy = input.question("How long will you study daily (in minutes)? ");
let timeInYear = 365 * Number(timeStudy) / 60;
let timeInMonth = 30 * Number(timeStudy) / 60;
let timeInWeek = 7 * Number(timeStudy) / 60;
console.log(`\nIf you study ${timeStudy} a day of ${studyTopic},
you will study ${timeInWeek} hours per week
${timeInMonth} hours per month
and ${timeInYear} hours per year.`);
console.log();
let goalStudy = input.question("How many hours do you want to study? ");
let studyPeriod = input.question("Over how many days do you want to reach this goal? (week = 7, month = 30, year = 365) ");
let calculatedStudyDaily = (Number(goalStudy) / Number(studyPeriod)) * 60;
console.log("If you want to study " + goalStudy + " hours of " + studyTopic + " over " + studyPeriod + " days, it will take you " + calculatedStudyDaily + " minutes a day.");
*/