Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask C/C++ Expert


Home >> C/C++

Conditional Statements

Question 1: Write a program that computes the cost of a long distance call. The cost of the call is determined according to the following rate schedules.

  • A call made between 8:00 AM and 6:00 PM is billed at a rate of 6 rupees per minute.
  • A call made before 8:00 AM or after 6:00 PM is charged at a rate of 3.75 rupees.

According to this schedule, if a call starts at any time between 8:00 AM and 6:00 PM, and it ends after 6:00 PM then it will be charged at the rate of 6 rupees per minute for the time before 6:00 PM and for the rest of the time the rate will be 3.75 rupees per minute. For example if a call starts at 5:55 PM and ends at 6:05 PM then the charges on this call will be 48.75 (30 rupees for first 5 minutes and 18.75 rupees for rest of the time).

 

Similarly if a call starts at the time before 8:00 AM but ends after 8:00 AM then it will be charged at the rate of 3.75 rupees for the time before 8:00 AM and for remaining minutes after 8:00 AM the rate will be 6 rupees per minute. For example if a call starts at 7:49 AM and ends at 8:01 AM the charge on that call will be 47.25 rupees (41.25 for first 11 minutes and 6 rupees for last minute).

The input to the program will consist of the time the call started, and the length of call in minutes. The output will be the cost of call. The time is to be input in 24-hours notation, so the time 1:30 PM is input as 13:30. The time will be input using two variables of type int, one used for hour and other used for minutes. The number of the minutes for length of the call will also be input as a value of type int.      

After completing the program test it for following inputs.

Input

Output

Start time

Length

Cost

8: 21

10

60

17:55

10

 

7:49

12

 

6:00

30

 

8:00

5

 

Question 2: You are required to modify the program written for calculating call charges according to the following schedule.

  • Any call made between 8:00 AM and 6:00 PM, Monday through Friday, is billed at a rate of 6 rupees per minute.
  • Any call made before 8:00 AM or after 6:00 PM, Monday through Friday, is charged at a rate of 3.75 rupees per minute.
  • Any call made on a Saturday or Sunday is charged at a rate of 1.5 rupees per minute.

The modified program will also input the day of the week along with the other inputs. The day of the week will be read as one of the following pairs of character values, which are stored in two variables of type char:

Su                  Tu Th Sa                           We Fr Su

 

The rules for calculating the charges for a call are same as in the previous program with following enhancements.

If a call is started on Friday at 11:55 PM and ends at 12:05 AM on Saturday then the rate of the call will be calculated as cost of call as per schedule on Friday for first 5 minutes, plus the cost of call as per schedule on Saturday for rest of the 5 minutes. Similarly, if a call starts on Sunday at 11:55 PM and ends at 12:05 AM on next day i.e. Monday, then the cost of the call will be calculated as charges as per schedule on Sunday plus the charges as per schedule on Monday.

After completing the program test it for following inputs.

Input

Output

Start time

Length

Day

Cost

8: 21

10

Monday

60

17:55

10

Tuesday

 

7:49

12

Friday

 

6:00

30

Sunday

 

23:55

10

Friday

 

23:51

20

Sunday

 

 

 

 

 

 

C/C++, Programming

  • Category:- C/C++
  • Reference No.:- M9291462

Have any Question?


Related Questions in C/C++

What are the legal requirements with which websites must

What are the legal requirements with which websites must comply in order to meet the needs of persons with disabilities? Why is maximizing accessibility important to everyone?

1 implement the binary search tree bst in c using the node

1. Implement the Binary Search Tree (BST) in C++, using the Node class template provided below. Please read the provided helper methods in class BST, especially for deleteValue(), make sure you get a fully understanding ...

Assignment word matchingwhats a six-letter word that has an

Assignment: Word Matching What's a six-letter word that has an e as its first, third, and fifth letter? Can you find an anagram of pine grave. Or how about a word that starts and ends with ant (other than ant itself, of ...

Project - space race part a console Project - Space Race Part A: Console Implementation

Project - Space Race Part A: Console Implementation INTRODUCTION This assignment aims to give you a real problem-solving experience, similar to what you might encounter in the workplace. You have been hired to complete a ...

Software development fundamentals assignment 1 -details amp

Software Development Fundamentals Assignment 1 - Details & Problems - In this assignment, you are required to answer the short questions, identify error in the code, give output of the code and develop three C# Console P ...

Question 1find the minimum and maximum of a list of numbers

Question: 1. Find the Minimum and Maximum of a List of Numbers: 10 points File: find_min_max.cpp Write a program that reads some number of integers from the user and finds the minimum and maximum numbers in this list. Th ...

Why do researcher drop the ewaste and where does it end

Why do researcher drop the ewaste and where does it end up?

Assign ment - genetic algorithmin this assignment you will

ASSIGN MENT - GENETIC ALGORITHM In this assignment, you will use your C programming skills to build a simple Genetic Algorithm. DESCRIPTION OF THE PROGRAM - CORE REQUIREMENTS - REQ1: Command-line arguments The user of yo ...

There are several ways to calculate the pulse width of a

There are several ways to calculate the pulse width of a digital input signal. One method is to directly read the input pin and another method (more efficient) is to use a timer and pin change interrupt. Function startTi ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As