Vous êtes sur la page 1sur 3

STIA1014 Assignment 1

Direction:

Answer all of the following questions.


Submit your hard copy (source codes & sample ouputs) and soft copy (source codes)
via email muhammad@uum.edu.my
Assignment should be done individually

Date due:

28/10/2014; 1130 Wednesday 12 Oclock midnight

1. Write a program that can to convert an amount of money in United


States Dollar (USD) to a choices of either Malaysian Ringgit (RM), Euro
(EU), or Saudi Riyal (SR). Read the exchange rate from the user.

2. For the Malaysian ringgit the user obtained as exchange for the US
dollar in Question 1, extend your program so that it will display how
many RM50 notes and RM10 notes a person should receive for a given
amount of money whenever the amount exchange is more than RM 90.
For example, if the amount is RM220, the number of RM50 notes is 4
and the number of RM10 notes is 2. Your program should be able to
reproduce the following sample run:

The amount of money= RM220


Number of RM50 = 4
Number of RM10 = 2

3. Write a program that can calculate the monthly payment for a loan
amount. Use the following loan payment formula to calculate the loan
monthly payment :

Where
P = principal, the amount of the loan
I = the annual interest rate (from 1 to 100 percent)
L = length, the length (in years) of the loan,
J = monthly interest in decimal form, J = I / (12 x 100)
N = number of months over which loan is amortized, N= L x 12
The input for your program: P, I and L.
The output : M.

4. Write a program ReplaceTester that encodes a string by replacing all


letters "i" with "!" and all letters "s" with "$". Use the replace method.
Demonstrate that you can correctly encode the string "Mississippi".
Print both the actual and expected result.

5. Write a program that can calculate and display how long it takes to
download a file. To do the calculation, the program will ask the user to
input the size of the file in megabytes (Mb) and the download speed in
Mb per second. The program will then output the download duration (in
hour, minute and second). Sample output (red color indicates value
entered by the user):

Welcome to the download estimator.

Enter the file size (MB) = 800


Enter the download speed (MB/sec) = 1

This download will take approximately 0 hours 13 minutes and 20 seconds

6. The Pizza House wants you to write a program that simulates a simple
cash register. The program firstly should ask the user to enter the price
of the meal. Then, the program should calculate the sales tax (8.25% of
the meal price) and add it to the meal price to obtain the total price,
which should be displayed to the user. The program then ask for the
amount tendered (the amount customer gives to pay the bill). After the
user entered the amount tendered, the program should display the
amount tendered, the total price of the meal and the change amount.

Sample output (red color indicates value entered by the user) :

**** Pizza House ******

Enter the price of meal (RM): 52.95


Price of Meal: 52.95
Sales Tax: 4.37
--------------------------------

Total Amount: 57.32


Enter amount tendered (RM): 70.00

Amount Tendered: RM: 70.00


Total Amount: RM: 57.32
--------------------------------
Change: RM: 12.68

**** Thank You *****


NOTE: To format the output as given above, you must use the
System.out.printf() method.

7. Write a program that reads in three floating-point numbers and prints the three inputs in sorted
order. For example:

Please enter three numbers:

4
9
2.5

The inputs in sorted order are:

2.5
4
9

Vous aimerez peut-être aussi