Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Lab for loops. I need it in C++ and to run this on code blocks In this lab youll be using for loops to perform

Lab for loops. I need it in C++ and to run this on code blocks

In this lab youll be using for loops to perform various calculations. In parts (a) and (b) of the lab, the counting variable will be used as part of the calculation inside the for loop. For parts (c) and (d) the counting variable will be used purely for counting and not as part of the calculations.

Lab a

Use a for loop to loop through the values 10, 20, 30 100. Each time through the loop, display the number of miles and its equivalent in kilometers.

image text in transcribed

Lab b

Use a for loop to loop through the numbers 97, 98, 99 122. Display the number and then typecast it to a character and display the character whose ASCII code is the number you just displayed.

image text in transcribed

lab c

Use a for loop to simulate the addition of interest to a savings account. Ask the user for an account balance, interest rate and number of years. Then loop as many times as specified by the number of years. Each time through the loop, update the account balance with an additional years worth of interest.

image text in transcribed

Lab d

Use a for loop to generate 10 random math problems. Choose two random numbers between 1 and 100 and then randomly choose whether the user should add, subtract or multiply the numbers. To choose an operation randomly, generate one of three random numbers (e.g. 1 3), then if the computer chooses 1, you can treat that as add, etc. As shown in the output below, have the user type in what they think is the answer to each problem (what is after the = in the output below). Then, tell the user if they are correct or incorrect.

image text in transcribed

sivisual studio 20101Projects Lab 4 Debug Lab 4.exe Miles Kiloneters 16.093 32.1868 48.2802 64.3736 80.467 96.5604 112.654 128.747 144.841 160.934 40 50 60 80 90 100

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

Filing And Computer Database Projects

Authors: Jeffrey Stewart

2nd Edition

007822781X, 9780078227813

More Books

Students also viewed these Databases questions

Question

1. Organize and support your main points

Answered: 1 week ago

Question

3. Move smoothly from point to point

Answered: 1 week ago

Question

5. Develop a strong introduction, a crucial part of all speeches

Answered: 1 week ago