Solved Homework: Question: Develop a functional flowchart and then write a menu-driven C++ program, using control constructs…

Develop a functional flowchart and then write a menu-driven C++ program, using control constructs and user-defined functions, to solve for the following problem. (Note: declare the parking fee schedule in const variables. Never use the bare bone constant values shown) The sign on the attendant’s booth at the parking lot is: Visitors Parking Cars: First 1 Hours: Free Next 2 hours: $ 2.00 per hour Next 5 hours: $ 1.0 per hour Thereafter: $ 0.50 per hour (more than 8 hours) Motorcycles: First 1 hour: $ 1.00 Next 5 hours: $ 0.50 per hour Next 8 hours: $ 0.25 per hour Thereafter: $ 0.10 per hour (more than 14 hours) Senior Citizens: Free Upon execution of the program, the screen will be cleared and the following menu will appear at the top of the screen, properly centered: Help Cars Motorcycles Senior Citizens Quit

1) H or h (for Help) option will briefly explain how the program should be used. Display of the parking fees shown above along with explanatory notes will help here. Once the user finishes reading the help screen(s), striking any key (strike a key followed by Enter key) will clear the screen and the menu is displayed again. The text for this help menu should be read from an ASCII text file.

2) C or c (for Cars) option will prompt the user for the number of minutes a vehicle has been in the lot. The program should then compute the appropriate charge and display the ticket on the monitor for the customer, as well as writing/adding the same to an ASCII file called parking_Charges. Any part of an hour is to be counted as a full hour (e.g., 65 minutes will be two hours.) Once the user finishes viewing the ticket, striking any key will clear the screen and the above menu is displayed again.

3) M or m (for Motorcycles) option will prompt the user for the number of minutes a vehicle has been in the lot. The program should then compute the appropriate charge and display the ticket on the monitor for the customer, as well as writing/adding the same to an ASCII file called parking_Charges. Any part of an hour is to be counted as a full hour (e.g., 45 minutes will be one hour.) Once the user finishes viewing the ticket, striking any key will clear the screen and the menu is displayed again.

4) S or s (for Senior Citizens) option will prompt the user for the number of minutes a vehicle has been in the lot. The program performs no computations. The ticket should show $0.00, and this information should be written/added to an ASCII file called parking_Charges. Once the user finishes viewing the ticket, striking any key will clear the screen and the menu is displayed again.

5) Q or q (for Quit) option will clear the screen and returns the control to the programmer’s IDE.

Test your program with the values shown below. For option C, c : 0, 45, 85, 120, 140, 360, 960, 1050, and 1510 minutes For option M, m : 0, 55, 60, 120, 155, 175, 180, 220, 850, and 1550 minutes For option S, c : 0, 200, and 380 minutes Of course, your program will work for other values within the integer boundary

Expert Answer

answers

Create text files named parking_charges and help in the directory/folder where your C++ programs are stored.

This code is for standardised C++ compiler like G++.

#include<iostream>

#include<stdio.h>

#include<stdlib.h>

void menu(){

std::cout<<“ttttVISITORS PARKINGn”;

std::cout<<“H or h (for Help)n”;

std::cout<<“C or c (for Cars)n”;

std::cout<<“M or m (for Motorcycles)n”;

std::cout<<“S or s (for Senior citizens)n”;

std::cout<<“Q or q (for Quit)n”;

}

void helpInfo(){

FILE* fp = fopen(“help.txt”, “r”);

if(fp == NULL){

std::cout<<“File not found !n”;

return;

}

char c[100];

while(fgets(c, 99, fp) != NULL){

std::cout<<c;

}

std::cout<<std::endl;

}

int main()

{

// here 1 is 1 hour, 2 is next 2 hrs, 5 is next 5 hrs and 8 is more than 8 hrs

const double CAR1 = 0.0; // free for 1 hour

const double CAR2 = 2.0; // $2 per hour

const double CAR5 = 1.0; // $1 per hour

const double CAR8 = 0.5; // $0.5 per hour

const double MOTOR1 = 1.0;

const double MOTOR5 = 0.5;

const double MOTOR8 = 0.25;

const double MOTOR14 = 0.10;

FILE *fp = fopen(“parking_charges.txt”, “a+”); // file pointer

if(fp == NULL)

{

std::cout<<“File not foundn”;

return -1;

}

menu();

char ch;

int mins;

int hrs;

double amt;

do

{

std::cout<<“———————————————————-n”;

std::cout<<“Enter your choice: “;

std::cin>>ch;

hrs = 0;

amt = 0.0;

switch(ch)

{

case ‘H’:

case ‘h’:

helpInfo();

system(“pause”);

system(“cls”);

break;

case ‘C’:

case ‘c’:

std::cout<<“Enter minutes: “;

std::cin>>mins;

while(mins >= 60)

{

hrs++;

mins = mins – 60;

}

// used if less than 60 mins left

if(mins > 0)

{

hrs++;

}

if(hrs <= 1)

{

amt = 0.0;

}else if(hrs > 1 && hrs <= 3)

{

amt = CAR1 + (hrs – 1) * CAR2;

}else if(hrs > 3 && hrs <= 8)

{

amt = CAR1 + (2)*CAR2 + (hrs – 3) * CAR5;

}else if(hrs > 8)

{

amt = CAR1 + (2 * CAR2) + (5 * CAR5) + ((hrs – 1 – 2 – 5) * CAR8);

}

std::cout<<“Amount to be paid: ” <<amt<<“n”;

fprintf(fp, “%lfn”, amt); // write to file

system(“pause”);

system(“cls”);

break;

case ‘m’:

case ‘M’:

std::cout<<“nEnter minutes: “;

std::cin>>mins;

while(mins >= 60)

{

hrs++;

mins = mins – 60;

}

// used if less than 60 mins left

if(mins > 0)

{

hrs++;

}

if(hrs <= 1)

{

amt = MOTOR1;

}

else if(hrs > 1 && hrs <= 6)

{

amt = MOTOR1 + (hrs – 1) * MOTOR5;

}

else if(hrs > 6 && hrs <= 14)

{

amt = MOTOR1 + (5 * MOTOR5) + (hrs – 1 – 5)* MOTOR8;

}

else if(hrs > 14)

{

amt = MOTOR1 * (5 * MOTOR5) + (8 * MOTOR8) + ((hrs – 1 – 5 – 8) * MOTOR14);

}

std::cout<<“Amount to be paid: ” <<amt<<“n”;

fprintf(fp, “%lfn”, amt); // write to file

system(“pause”);

system(“cls”);

break;

case ‘s’:

case ‘S’:

amt = 0.0;

std::cout<<“nEnter minutes: “;

std::cin>>mins;

std::cout<<“Amount to be paid: ” <<amt<<“n”;

fprintf(fp, “%lfn”, amt); // write to file

system(“pause”);

system(“cls”);

break;

case ‘q’:

case ‘Q’:

goto label;

break;

default:

std::cout<<“Invalid choicen”;

break;

}

menu();

}while(ch != ‘q’ || ch != ‘Q’);

label:

fclose(fp);

return 0;

}

Buy Essay
Calculate your paper price
Pages (550 words)
Approximate price: -

Help Me Write My Essay - Reasons:

Best Online Essay Writing Service

We strive to give our customers the best online essay writing experience. We Make sure essays are submitted on time and all the instructions are followed.

Our Writers are Experienced and Professional

Our essay writing service is founded on professional writers who are on stand by to help you any time.

Free Revision Fo all Essays

Sometimes you may require our writers to add on a point to make your essay as customised as possible, we will give you unlimited times to do this. And we will do it for free.

Timely Essay(s)

We understand the frustrations that comes with late essays and our writers are extra careful to not violate this term. Our support team is always engauging our writers to help you have your essay ahead of time.

Customised Essays &100% Confidential

Our Online writing Service has zero torelance for plagiarised papers. We have plagiarism checking tool that generate plagiarism reports just to make sure you are satisfied.

24/7 Customer Support

Our agents are ready to help you around the clock. Please feel free to reach out and enquire about anything.

Try it now!

Calculate the price of your order

Total price:
$0.00

How it works?

Follow these simple steps to get your paper done

Place your order

Fill in the order form and provide all details of your assignment.

Proceed with the payment

Choose the payment system that suits you most.

Receive the final file

Once your paper is ready, we will email it to you.

HOW OUR ONLINE ESSAY WRITING SERVICE WORKS

Let us write that nagging essay.

STEP 1

Submit Your Essay/Homework Instructions

By clicking on the "PLACE ORDER" button, tell us your requires. Be precise for an accurate customised essay. You may also upload any reading materials where applicable.

STEP 2

Pick A & Writer

Our ordering form will provide you with a list of writers and their feedbacks. At step 2, its time select a writer. Our online agents are on stand by to help you just in case.

STEP 3

Editing (OUR PART)

At this stage, our editor will go through your essay and make sure your writer did meet all the instructions.

STEP 4

Receive your Paper

After Editing, your paper will be sent to you via email.

× How can I help you?