Assignment No. 1
Assignment No. 1
Instructions
1. Understanding the problems is part of the assignment. So, no query, please.
2. You will get zero marks if found any type of plagiarism.
3. No submission after due date.
4. Upload pdf file containing your code and screenshots of outputs.
5. Include your name, SAP ID, section and task number as cout statements in each program.
Your Output should start by these details.
Task 1: The population of a town A is less than the population of town B. However, the population
of town A is growing faster than the population of town B. Write a program that prompts the user to
enter the population and growth rate of each town. The program outputs after how many years the
population of town A will be greater than or equal to the population of town B and the populations of
both the towns at that time. (A sample input is: Population of town A = 5000, growth rate of town A
= 4%, population of town B = 8000, and growth rate of town B = 2%.) [2.5]
Task 2: Write a program that generates a multiplication table for numbers from 1 to 10. The
program should use nested for loops to generate the table. However, the program should only display
the products of numbers that are even. Additionally, the program should prompt the user to enter the
starting and ending numbers for the table. If the user enters an invalid input (e.g. a letter instead of a
number), the program should display an error message and prompt the user to enter a valid number.
{Explore cin. clear() & cin.igore()} [2.5]
Task 3: Write a program that calculates how much a person would earn over a period of time
if his or her salary is one penny the first day and two pennies the second day, and continues to double
each day. The program should ask the user for the number of days. Display a table showing how
much the salary was for each day, and then show the total pay at the end of the period. The output
should be displayed in a dollar amount, not the number of pennies. Input Validation: Do not accept
a number less than 1 for the number of days worked. [2.5]
Task 4: Write a program that displays a menu allowing the user to select an addition,
subtraction, multiplication, or division problem. The final selection on the menu should let the user
quit the program. After the user has finished the math problem, the program should display the menu
again. This process is repeated until the user chooses to quit the program. Input Validation: If the
user selects an item not on the menu, display an error message and display the menu again, if a user
enters a 0 as divisor, it should display error message and input divisor again until a valid input. [2.5]