Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a program that uses a function to print the following pattern. Asks the user to enter an odd integer between 1 and 10 (both

Write a program that uses a function to print the following pattern. Asks the user to enter an odd integer between 1 and 10 (both inclusive). Make sure to check that the user has entered a value between this range and if not, keep asking until the user enters a correct integer. This integer is passed to the function, which produces the pattern based on the value of that integer. For example, if the integer value was 3, then the function prints out the following pattern on screen.

*

***

*

If the value was 5, then the function prints the pattern as follows:

*

***

*****

***

*

And so on for other odd values less than 10. Your function should strictly use nested loops and cout <<* as the only statement in it along with other necessary formatting instructions.

2. (Perfect Numbers) An integer is said to be a perfect number if the sum of its factors, including 1 (but not the number itself), is equal to the number. For example, 6 is a perfect number, because 6=1+2+3. Write a program that uses a function called perfect that determines whether parameter integer is a perfect number. Use this function in a program that determines and prints all the perfect numbers between 1 and 1000. Print the factors of each perfect number to confirm that the number is indeed perfect.

For fun, challenge the power of your computer by testing numbers much larger than 1000.

3. Write a C++ program similar to the ones used in ATM machines. Essentially your program is to handle a person's savings and checking accounts and should handle the following services:

Transfer from savings account to checking account

Transfer form checking account to savings account

Cash withdrawal from either accounts

Balance statements for both the accounts

Assume that the ATM machine recognizes a unique 3-digit personal idenitification number (PIN). In your initial screen you are to first ask the user to type in his/her PIN as follows:

*** Welcome to Cal ATM ****

Please enter your PIN:

In response to this, the user has to enter a valid PIN. Assume that the only legal PIN is:

111

If any number besides this PIN is entered, the screen is to be cleared

and the same screen to be redisplayed. The user then gets a second chance

to enter a valid PIN. If an illegal PIN is entered three consecutive, the following message:

Too many illegal PINs. Try later again.

should appear on the screen and your program must terminate. If the entered PIN is a legal value, the main menu is to be displayed as follows:

*** Welcome To Cal ATM System ***

(1) Transfer from checking account to savings account

(2) Transfer from savings account to checking account

(3) Savings account balance

(4) Checking account balance

(5) Withdraw Cash from either account

(6) Exit

==> Please select option (1-6):

The following are some of the guidelines you should follow:

Guidelines

-- The main menu is to continue to be displayed until user selects option 6. At this point a message such as

Thank you for using the ATM system.

should appear and your program execution is to be terminated.

-- Users have to select options 1, 2, 3, 4, 5 or 6. Redisplay the menu if any number outside the range 1 to 6 is entered (Hint: Use system("cls") command from library to clear the screen)

-- Withdrawl (selection 5) should ask wether the user wants to withdraw from checking account or saving account and should subtract the amount specified

from the appropriate account.

-- Savings and checking accounts both have initial balance of $1000.00

-- Any transfer is allowed only if it can be honored. For example, if the savings account balance is $500.00 and the user requests to transfer $550.00 from that savings account to the checking account an appropriate message such as

"Transasction not completed"

should be displayed and the current balance of that account should be printed.

The screen is to be cleared and the main menu to be displayed.

-- Write your own functions for each case. Please use reference variables and value variables correctly as needed in the functions.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle Database 19c DBA By Examples Installation And Administration

Authors: Ravinder Gupta

1st Edition

B09FC7TQJ6, 979-8469226970

More Books

Students also viewed these Databases questions

Question

What is the Definition for Third Normal Form?

Answered: 1 week ago

Question

Provide two examples of a One-To-Many relationship.

Answered: 1 week ago