If Statement-Computer Programming-Lab Assignment, Exercises of Computer Engineering and Programming

This is lab task for Computer Programming course. It was assigned by Sonia Singh at Alliance University. It includes: Program, If, Statement, Select, Input, Decision, Access, Display, Arithmetic, Operations, Bitwise

Typology: Exercises

2011/2012

Uploaded on 07/12/2012

vish
vish 🇮🇳

3 documents

1 / 2

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
- 1 -
COMPUTER PROGRAMMING
SPRING 2012
ASSIGNMENT II
Note: Implement the given programs in to C++ using If Statement and show the menu
on screen as well wherever user have to select any option.
Program-1: Write a program to get name and age (in years) of a person. Prompt the
user to select the choice, if the user selects „m‟ then calculate the age in months, if the
user selects „d‟ then calculate the age in days and print the name of person and its age
in months/days on the screen otherwise print any appropriate message if the user enters
any wrong option.
Program-2: The LeVan Car Rental company charges $0.25/mile if the total mileage
does not exceed 100. If the total mileage is over 100, the company charges $0.25/mile
for the first 100 miles, then it charges $0.15/mile for any additional mileage over 100.
Write a program so that if the clerk enters the number of miles, the program would
display the total price owed.
Program-3: Write a program to input five integer values and find out the greatest and
the smallest of all the five entered numbers with appropriate messages.
Program-4 Write a program to input five numbers from user and check the number are
divisible by 3 then print the message on the screen that “the number is divisible by
three”. Otherwise print “The number is not divisible by three”.
Program-5: Write a program that takes input from user for username and if username
is correct then
only asks for password and makes decision whether to give access to some application
or not (Display Appropriate Messages for this purpose).
Program-6: Write a program that takes a number from the user and tells what is the
equivalent month of this entered number e.g. if the user enters 6 then system should
display it is JUNE.
Program-7: Write a program that takes three inputs from the user two are the integers
and one is the character, if user enters „O‟ perform the Bitwise OR operation on the
entered numbers if the user enters „A‟ perform the Bitwise AND operation on the
entered numbers if the user enters „N‟ perform NOT on any of the entered number and
if the user selects a wrong option display the appropriate messages.
Program-8: There are different type of bank account are mentioned in the following
table and according to the account type interest rates are given, implement a program
which will take the total amount balance in the bank account of the account holder and
according to the account type calculate the total amount by applying interest on the
actual amount.
Account
Type
Account
Description
Interest
Rate
Docsity.com
pf2

Partial preview of the text

Download If Statement-Computer Programming-Lab Assignment and more Exercises Computer Engineering and Programming in PDF only on Docsity!

COMPUTER PROGRAMMING

SPRING 2012

ASSIGNMENT– II

Note : Implement the given programs in to C++ using If Statement and show the menu on screen as well wherever user have to select any option.

Program-1 : Write a program to get name and age (in years) of a person. Prompt the user to select the choice, if the user selects „m‟ then calculate the age in months, if the user selects „d‟ then calculate the age in days and print the name of person and its age in months/days on the screen otherwise print any appropriate message if the user enters any wrong option.  Program - 2: The LeVan Car Rental company charges $0.25/mile if the total mileage does not exceed 100. If the total mileage is over 100, the company charges $0.25/mile for the first 100 miles, then it charges $0.15/mile for any additional mileage over 100. Write a program so that if the clerk enters the number of miles, the program would display the total price owed.  Program-3: Write a program to input five integer values and find out the greatest and the smallest of all the five entered numbers with appropriate messages.  Program-4 Write a program to input five numbers from user and check the number are divisible by 3 then print the message on the screen that “the number is divisible by three”. Otherwise print “The number is not divisible by three”.  Program-5: Write a program that takes input from user for username and if username is correct then  only asks for password and makes decision whether to give access to some application or not (Display Appropriate Messages for this purpose).  Program-6: Write a program that takes a number from the user and tells what is the equivalent month of this entered number e.g. if the user enters 6 then system should display it is JUNE.  Program-7: Write a program that takes three inputs from the user two are the integers and one is the character, if user enters „O‟ perform the Bitwise OR operation on the entered numbers if the user enters „A‟ perform the Bitwise AND operation on the entered numbers if the user enters „N‟ perform NOT on any of the entered number and if the user selects a wrong option display the appropriate messages.

Program-8: There are different type of bank account are mentioned in the following table and according to the account type interest rates are given, implement a program which will take the total amount balance in the bank account of the account holder and according to the account type calculate the total amount by applying interest on the actual amount.

Account Type

Account Description

Interest Rate

Docsity.com

P

personal financial 2.3%

H (^) personal homeowner

G (^) personal gold 2.9% S (^) small business 2.6% B big business 2.9% O gold business 3.0%

Directions: Understand the Problems thoroughly and implement them by yours own don‟t copy or cheat of any of yours mate because demonstration in class of individual student will be held according to the given plan of five students in a class, in case of plagiarism detected the person will be directly given 0. Good luck and May Allah Pak bless you.

Deadline: 13 th^ March 2012

Docsity.com