- Lakehead University
- CS 1411 COMPUTER PROGRAMMING I
- Assignment No. 2
- Instructor: Dr. Jinan FIAIDHI
- 1. Write a program that prompts the user to input an integer between 0 and 35. If the number is less than or equal to 9, the program should output the number; otherwise, it should output A for 10, B for 11, C for 12…, and Z for 35.
- 2. In a right triangle, the square of the length of one side is equal to the sum of the squares of the lengths of the other two sides. Write a program that prompts the user to enter the lengths of three sides of a triangle and then outputs a message indicating whether the triangle is a right triangle.
- 3. 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 and appropriate message.) Some sample outputs follow:
- 4. A bank in your town updates its t customer's 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 customer's balance falls below the minimum balance, 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:
- a) Savings accounts receive 4% interest.
- b) Checking accounts with balances up to $5,000 more than the minimum balance receive 3% interest; otherwise, the interest is 5%.
- write a program that reads a customer's account number (int type), account type (char; S for savings, C for checking), minimum balance that the account should maintain, and current balance. The program should then output the account number, account type, current balance and appropriate message . Test your program by running five times, using the following data:
- 46728 S 1000 2700
- 87324 C 1500 7689
- 79873 S 1000 800
- 89832 C 2000 3000
- 98322 C 1000 750.
- 5. Write a program that calculates and prints the bill for a cellular telephone company. The 2 types of services: regular and premium. Rates vary based on the type of service and are computed as follows:
- Regular service: $10 plus first 50 minutes are free. Charges for over 50 minutes are $.20 per minute.
- Premium service: $25 plus:
- A. for calls made from 6:00 am to 6:00pm, the first 75 minutes are free; charges over 75 minutes are $.10 per minute.
- B. for calls made from 6:00 pm to 6:00 am, the first 100 minutes are free. Charges over 100 minutes are $.05 per minutes.
- Your program should prompt the user to enter an account number, a service code (type char), and the number of minutes the service was used. A service code of r or R means regular service; a service code of p or P means premium service. Treat any other character as an error. Program should output the account number, type of service, number of minutes the telephone service was used, and amount due from the user.
- For the premium service, the customer may be using the service during the day and the night. Therefore, to calculate the bill, you must ask the user to input the number of minutes the service the service was used during the day and the number of minutes the service was used at night.
- Due on October 14
a guest Oct 5th, 2010 248 Never
RAW Paste Data