Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Lab Programming # 3 LOOPS Part | Start your program by asking the user how much money their bank account had at the start of

image text in transcribed
Lab Programming # 3 LOOPS Part | Start your program by asking the user how much money their bank account had at the start of the day and how many bank transactions were done that day. Then in a loop, for each transaction do the following: 1. Ask for the type of transaction - debit or credit. Also ask for the amount of the transaction. 2.1f debit, subtract the amount from the account. If credit, add the amount. 3. Print out the total in the account after this transaction. When all transactions are complete: Print the total in the account at the end of the day. Extra Credit: Print total debit and total credit amounts for the day. Part |l Your program will simulate a lost robot taking steps in a random matter. The robot begins in the middle of Manhattan. Each time the robot moves one block, either north, south, east with probability 25% of each. You can use the following code to determine which direction the robot will move at each step. srand (time (0)) ; int direct; direct = rand{() % 4 + 1; //random number between 1 and 4 so each is 25% //probable //1 means North, 2 means South, 3 means East and 4 means T = West 1. The robot moves 25 times. At each step, how many blocks away (print this in north or south, east or west of the starting point) is the robot from the starting point? 2. You want the robot to get to a point that is 2 blocks to the east and 3 blocks to the north of the starting point. Given the same random choices for moves, change your code so that your code prints out how many steps it took to get to the destination point. 3. Extra Credit: On average, how many steps does it take for the robot to reach the destination point? Run #2 above 10 times and give the average! Al

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

Mobile Communications

Authors: Jochen Schiller

2nd edition

978-0321123817, 321123816, 978-8131724262

More Books

Students also viewed these Programming questions

Question

Pollution Human Activities?

Answered: 1 week ago

Question

Major global environmental Threats ?

Answered: 1 week ago

Question

Socratic method ?

Answered: 1 week ago