• Home
  • About
    • Cong-Yao Huang's Personal Homepage photo

      Cong-Yao Huang's Personal Homepage

      Moon is a minimal, one column jekyll theme for your blog.

    • Learn More
    • Facebook
    • LinkedIn
    • Instagram
    • Github
  • Posts
    • All Posts
    • All Tags
  • Projects

Homework 1 : Basics

02 Apr 2018

Reading time ~1 minute

1   Bill Generator

We want to create a telecommunication bill for a customer from screen inputs:

<billing_date>
Dear <firstname> customer:
The following is this month's billing details.

Bill cycle: from <date1> to <date2>

Base plan:..........................<base>
Local calls:........................<local>
International calls:................<int>
Tax: (<base>+<local>+<int>)*9%......[tax]
Total:..............................[total]


Please pay the above total by <pay_date>.

Billing Department
One Telecommunication

In the above example bill, texts in <> will be replaced by the actual information. You will use cin to obtain these information from the terminal and then output the complete email. The following is an example run: Note that [tax] and [total] are calculated by your program.

August 2nd, 2014
Dear Peta customer:
The following is this month's billing details.

Bill cycle: from 07/01/2014 to 08/01/2014

Base plan:..........................$50.00
Local calls:.........................$5.00
International calls:................$15.00
Tax: ($50.00+$5.00+$15.00)*9%........$6.30
Total:..............................$76.30


Please pay the above total by 08/12/2014.

Billing Department
One Telecommunication

Please write a program to generate above bill.

2   Unit Conversion

It has been defined by the US government that 1 inch equals to 2.54 centimeters, and 1 foot is 12 inches.
Your program should read in an integer that represents a length expressed in meters, and then convert it to US customary units of feet and inches. Typical program inputs and outputs are shown below.

Input length in meters: 3952 
Length in US customary units: 12965 feet 10 inches 
Input length in meters: 8848 
Length in US customary units: 29028 feet 10 inches


cpphwIO Share Tweet +1