Anda di halaman 1dari 3

Midterm Case Study

Fundamentals of Programming Database

Theory
C
Machine Problems
and Application
1. Write a program that will prompt the user to input items price and its discount value. It will then
output its discounted price.
Sample Run:

Enter items price: 585


Enter the discount value (%): 10
Discounted price: 526.6
2.

Write a program that will compute the amount of interest that is earned on P17, 000 invested at an
interest rate of 0.07 for one year. The interest and the value of the investment after one year are
printed to standard output.
Sample Run:

The interest earned is: P1190


The value of the investment after one year is: P18190
3. If you have N eggs, then you have N/12 dozen eggs, with N%12 eggs left over. Write a program that
asks the user how many eggs he has and then tells the user how many dozen eggs he has and how
many extra eggs are left over.
For example, if the user says that he has 100 eggs, then your program would respond with:

Your number of eggs is 8 dozen, and 4


Sample Run:

Enter the number of eggs: 100


Your number of eggs is 8 dozen, and 4
4.

Rewrite Machine Problem # 2 where it computes the amount of interest that is earned on an
investment over a period of one year. The initial amount of the investment and the interest rate are
input by the user. The value of the investment at the end of the year is output. The rate must be
input as a decimal, not a percentage (for example, 0.05 rather than 5).
Sample Run:

Enter the initial investment: 17000


Enter the annual interest rate (decimal, not percentage!):0.07
The value of the investment after one year is: P18190
5.

Write a program that mimics a calculator. The program should take as input two integers and the operation to be
performed. It should then output the numbers, the operator and the result. (For division, if the denominator is
zero, output an appropriate message).
Sample Run:
Enter two integers and the operation to be performed separated by spaces: 3 * 7
3 * 7 = 21
Note: Use switch structure

6.

At the Urdaneta City Fiesta 2011 Pie Eating Contest all contestants must weigh 250 pounds below. Write a
program that asks for a contestant's weight in kilograms and then says if the contestant is allowed in the contest.

7.

The cost of an international call from United States of America to Philippines is calculated as follows: connection
fee, $1.99; $2.00 for the first three minutes; and $0.45 for each additional minute. Write a program that prompts

cabatbatmark

Midterm Case Study

Fundamentals of Programming Database

Theory
C
and Application

Machine Problems

the user to enter the number of minutes the call lasted and outputs the amount due. Format your output with two
decimal places.
Sample Run:
Enter the number of minutes the call lasted: 7
8.

The amount due of the call is: $5.79


Write a program that would determine the fare per kilometer. Every 1 - 4 kilometer, the fare is P8.00 and in every
succeeding kilometer, you will add P2.50.
Sample Run # 1:
Enter kilometer(s): 4
You will pay P8.00 only. You succeeded 0 kilometer(s).

Sample Run # 2:
Enter kilometer(s): 6
You will pay P13.00 only. You succeeded 2 kilometer(s).
9.

Mark and Gracia's Delicatessen wants a program to take orders from the internet. The program will ask what item
the user wants, will ask its price, and will ask if the user wants overnight shipping. Regular shipping for items
under P500 is P100.00; for items P500 or more shipping is 150.00. For overnight delivery add P250.00.
Sample Run:
Enter the item:
Tuna Salad
Enter the price:
200
Overnight delivery? (0==No, 1==Yes):
1

Invoice:
Tuna Salad
200
Shipping
7.00
Total
350.00
10. A bank in your town updates its costumers accounts at the end of each month. The bank offers two types of
accounts: savings and checking. Every customer must maintain a minimum balance. If a customers balance falls
below the minimum, there is a service charge of $10.00 for savings accounts and $25.00 for checking accounts. If
the balance at the end of the month is at least the minimum balance, the account receives interest as follows:

Savings accounts receive 4% interest.


Checking accounts with balances of up to $5000 more than the minimum balance receive 3%
interest; otherwise, the interest is 5%.

Write a program that reads a customers account number (int type), account type (char; s for savings, c for
checking), minimum balance that the account should maintain, and the current balance. The program
should the output the account number, account type, current balance, and an appropriate message. Test your
program by running it five times, using the following data:
46728

1000

2700

87324

C 1500

7689

79873

1000

800

89832

2000

3000

98322

1000

750

Sample Run #1:


Enter the account number:
46728

cabatbatmark

Midterm Case Study

Fundamentals of Programming Database

Theory
C
Machine Problems
Enter the account type: [S / C]
S
Enter the minimum balance:
1000
Enter the current balance:
2700
The account number is: 46728
The account number is: Savings Account [S / s]
The current balance for this month is: $2808.00

Sample Run # 2:
Enter the account number:
87324
Enter the account type: [S / C]
C
Enter the minimum balance:
1500
Enter the current balance:
7689
The account number is: 87324
The account number is: Savings Account [C / c]
The current balance for this month is: $7919.67

cabatbatmark

and Application

Anda mungkin juga menyukai