Question

In C++ Write a program that will calculate the cost of a phone call as follows:...

In C++

Write a program that will calculate the cost of a phone call as follows:

  1. The first 10 minutes are charged at a flat rate of $0.99 for the entire 10 minutes (Not 99 cents a minute - but 99 cents for the first 10 minutes total).
  2. Every minute after the initial 10 minutes will be charged at $0.10 per minute.
  3. Input the number of minutes talked as an integer.
  4. Using an IF/ELSE structure, check for an entry of 0 minutes first, and inform the User that no minutes were entered.
    • IF 0 minutes are entered THEN
      • output an error message stating that no minutes were entered.
    • ELSE
      • Calculate and display the results.
      • The final display will show the minutes and the final cost.
      • The price will be formatted with 2 decimal places.
    • END IF
  5. Add the code necessary to allow the display window to stay open until you press a key from the keyboard:

system ("pause");

Include all Prologue information with your program

  • Include an Initial Algorithm
  • Include a Refined Algorithm
  • Include Input, Output, and Formulas (if there are any)
  • Test your program thoroughly with the following data:

1. 9 minutes
2. 10 minutes
3. 11 minutes
4. 35 minutes

NOTE 1:

  • DO NOT use the "return 0" code, end, break, or exit to force an exit from within your IF/ELSE structure.
    • Let the program progress to the end of the main function.
    • The end of the main function is the only place that the “return 0” should be placed.
    • A switch statement is the only place that the break command should be placed.
  • Declare all variables within the data declaration section.
  • DO NOT get input on the same line as a variable declaration.
  • DO NOT place an equation for computation on the same line as declaring a variable.

NOTE 2:
1. Declare all variables within the data declaration section of each class and method.  (-.1)
2   Do not get input on the same line as a variable declaration.  
(-.1)

3. Do not place an equation for computation on the same line as declaring a variable.  (-.1)

0 0
Add a comment Improve this question Transcribed image text
Answer #1

A) Initial Algorithm:

  • Get the user input for the number of minutes used.
  • If the user input is 0, print an error message saying that no minutes were entered.
  • Else,
    • If the minutes used is less than 10 minutes, then the final cost is $.99.
    • Else, find the final cost using the formula: 0.99 + (numberOfMinutes - 10)*0.1
  • Print the final cost.

c) INPUT: Number of minutes used by the user

OUTPUT: The final cost for the number of minutes used in dollars.

CODE

#include <iostream>

using namespace std;

int main() {

double finalCost;

int numberOfMinutes;

cout << "Enter the number of minutes used: ";

cin >> numberOfMinutes;

if (numberOfMinutes == 0) {

cout << "No minutes were entered." << endl;

} else {

if (numberOfMinutes <= 10) {

finalCost = 0.99;

} else {

finalCost = 0.99 + (numberOfMinutes - 10) * 0.1;

}

printf("The final cost is: $%.2f", finalCost);

}

system("pause");

return 0;

}

NOTE: Please explain what should go inside refined algorithm. Since I am not sure of what to include inside it, I have skipped it.

Add a comment
Know the answer?
Add Answer to:
In C++ Write a program that will calculate the cost of a phone call as follows:...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • WRITE THIS PROGRAM IN JAVA CODING ONLY ! Program 1: In Order Using an IF/ELSE IF/ELSE...

    WRITE THIS PROGRAM IN JAVA CODING ONLY ! Program 1: In Order Using an IF/ELSE IF/ELSE structure, write a program that will prompt the user for three numbers and displays them in ascending order. First, the program will prompt the user for each of the three numbers. Next, find the smallest value of the three. Then decide which of the other two is the next smallest. Then have the program display the three numbers in ascending order. Be sure to...

  • import java.util.*; /** Description: This program determines the average of a list of (nonnegative) exam scores....

    import java.util.*; /** Description: This program determines the average of a list of (nonnegative) exam scores. Repeats for more exams until the user says to stop. Input: Numbers, sum, answer Output: Displays program description Displays instruction for user Displays average Algorithm: 1. START 2. Declare variables sum, numberOf Students, nextNumber, answer 3. Display welcome message and program description 4. DOWHILE user wants to continue 5. Display instructions on how to use the program 6. Inititalize sum and number of student...

  • PLEASE WRITE CODE FOR C++ ! Time Validation, Leap Year and Money Growth PartA: Validate Day and Time Write a program tha...

    PLEASE WRITE CODE FOR C++ ! Time Validation, Leap Year and Money Growth PartA: Validate Day and Time Write a program that reads a values for hour and minute from the input test file timeData.txt . The data read for valid hour and valid minute entries. Assume you are working with a 24 hour time format. Your program should use functions called validateHour and validateMinutes. Below is a sample of the format to use for your output file  timeValidation.txt :   ...

  • Question2 uses structured design implemented in C. Array of records (structs) with file I/O is needed....

    Question2 uses structured design implemented in C. Array of records (structs) with file I/O is needed. The program takes two inputs at a time. The name of a person, and, the coin value as an integer in the range 5 to 95. Input coin values should always be divisible by 5 (integer division). Names are one word strings. An example input is: Jane 30 This input line indicates that 30 cents change is to be given to Jane. Output change...

  • Microsoft Visual Studios 2017 Write a C++ program that computes a student’s grade for an assignment...

    Microsoft Visual Studios 2017 Write a C++ program that computes a student’s grade for an assignment as a percentage given the student’s score and total points. The final score must be rounded up to the nearest whole value using the ceil function in the <cmath> header file. You must also display the floating-point result up to 5 decimal places. The input to the program must come from a file containing a single line with the score and total separated by...

  • In Java Code Needed is Below the Question Using Program 3: Encapsulating Dogs, modify this program...

    In Java Code Needed is Below the Question Using Program 3: Encapsulating Dogs, modify this program to create a database of dogs of your own. You will also include File I/O with this program. You will create 3 classes for this assignment. The first class: Create a Class representing the information that is associated with one item (one dog) of your database. Name this class Dog. Using Lab 3, this will include the information in regard to one dog. The...

  • C Language Programming. Using the program below - When executing on the command line only this...

    C Language Programming. Using the program below - When executing on the command line only this program name, the program will accept keyboard input and display such until the user does control+break to exit the program. The new code should within only this case situation “if (argc == 1){ /* no args; copy standard input */” Replace line #20 “filecopy(stdin, stdout);” with new code. Open read a text file “7NoInputFileResponse.txt” that contains a message “There were no arguments on the...

  • a C++ program that computes the cost of a long-distance call. The cost of the call...

    a C++ program that computes the cost of a long-distance call. The cost of the call is determined according to the following rate schedule: a. Any call started between 8:00 A.M. and 6:00 P.M., Monday through Friday, is billed at a rate of $0.40 per minute. b. Any call starting before 8:00 A.M. or after 6:00 P.M., Monday through Friday, is charged at a rate of $0.25 per minute. c. Any call started on a Saturday or Sunday is charged...

  • implicit none !   Declare File Read Variables     CHARACTER(255) :: Line     INTEGER :: CP !...

    implicit none !   Declare File Read Variables     CHARACTER(255) :: Line     INTEGER :: CP ! Character position in Line     INTEGER :: File_Read_Status !   Declare character constants     CHARACTER :: Tab > ACHAR(1)     CHARACTER :: Space = " " !   Read all lines in the file         DO             READ(*,'(A)',iostat = File_Read_Status) Line !       Exit if end of file             IF (File_Read_Status < 0) EXIT !       Skip leading white space          DO CP = 1, LEN_TRIM(Line)              IF...

  • Use Java Please File 1 and File 2 at bottom of post. 1. Write a program...

    Use Java Please File 1 and File 2 at bottom of post. 1. Write a program that compares two text files for equality. Print out any lines that are different along with the line number. 2. Include the following: File I/O Exception Handling using a Try/Catch Block Algorithm: Initial and Refined Internal Documentation All prologue information The two external files 3. Use the following two files: File1.txt and File2.txt. These files are included. I have also attached zip files containing...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT