write a c++ program that reads in the number of minute and seconds a call lasted
ID: 644024 • Letter: W
Question
write a c++ program that reads in the number of minute and seconds a call lasted. The program should then calculate the ttal cost for the call. The program should print the number of minutes the call lasted and the total cost for the call on seprrate ouutput lines. Print all monetoary amounts to two decimal places. assume there is a connection fee of $1.99 and then $2.00 for the first minute and $0.45 for each additional minute
For calls lasting less than 1 minute, the call is rounded up to be a minute. (For example, if a call lasted 0 minutes and 20 seconds, the call would be treated as 1 minute.)
For calls lasting over 1 minute, if the number of seconds is equal to or over 25, the call rounds up to the next minute.(For example if a call lasted 20 minutes and 30 seconds, the call would be treated as 21 minutes)
For calls lasting over 1 minute, if the number of seconds is less than 25, the number of seconds is disregarded. (For example if a call lasted 20 minutes and 20 seconds, the call would be treated as 20 minutes)
Explanation / Answer
Here what you have to do:
#include<iostream>
using namespace std;
int main(){
int num_min, num_sec;
cout <<"Enter number of minutes and seconds of call: ";
cin >> num_min >> num_sec;
double cost = 1.99;
if(num_min==0 && num_sec<60)
cost += 2.00;
else if(num_min>=1 && num_sec>=25)
cost += 2.00+0.45*(num_min);
else if(num_min>=1 && num_sec<25)
cost += 2.00+0.45*(num_min-1);
cout <<"Total cost of call is " << cost << endl;
return 0;
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.