C++ question: please answer the two questions #1 and #2 and separate them so I c
ID: 3887035 • Letter: C
Question
C++ question: please answer the two questions #1 and #2 and separate them so I can know. How can I output the difference between in the number of hours what is the formula. Please comment anything next to the two questions //1. Write a program that inputs the number of hours you are taking this semester and outputs how much time outside of class you should spend studying. (Hint: every 1 credit hour 2-3 hours spent outside of class). . Comment your program 2. Add on to this program another question to the user that asks them how many hours they actually spend studying and subtract the two values. Output the difference in the numbers of hours. o Comment your program
Explanation / Answer
#include<iostream>
using namespace std;
void numberOfHoursSpendingOutside(int creditHours){
// As 1 credit hour is equal to 2 to 3 hours spend outside studying
// So minimum will be 2*creditHours and max will be 3 *creditHours (So you must spend 2*creditHours to 3*creditHours studying outside)
int minNumberOfHoursSpendingOutside = 2 * creditHours;
int maxNumberOfHoursSpendingOutside = 3 * creditHours;
cout <<"You must spend "<<minNumberOfHoursSpendingOutside<<" to "<<maxNumberOfHoursSpendingOutside<<" hours studying outside"<<endl;
}
void diffHours(int creditHours, int actualHours){
int minNumberOfHoursSpendingOutside = 0;
minNumberOfHoursSpendingOutside = 2 * creditHours;
int diff = minNumberOfHoursSpendingOutside - actualHours;
cout<<"Difference between hours will be " << diff;
}
int main(){
// This will store the credit hours
int creditHours = 0;
cout<<"Enter the number of hours taking in this semester"<<endl;
cin>>creditHours;
// Prints the number the number of hours you must spend studying outside
numberOfHoursSpendingOutside(creditHours);
// Now taking program number two where user is asked for actual number of hours he spent for studying
int actualHours = 0;
cout<<"Enter the number of hours you actually spend studying"<<endl;
cin>>actualHours;
// Now we have to subtract the hours from you must spend to you actually spend
// As the user must spend 2*creditHours to 3*creditHours outside (So i am subtracting from 2*creditHours and actualHours) which will tell that minimum you
diffHours(creditHours, actualHours);
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.