Using Visual Studio, I need help with these Labs. Would appreciate all answers g
ID: 3672481 • Letter: U
Question
Using Visual Studio, I need help with these Labs. Would appreciate all answers greatly. Thank you.
Lab 5-1: Using a counter controlled while Loop:
In this lab, you use a counter-controlled while loop in a C++ program provided with the data files for this book. When completed, the program should print the numbers 0 through 10, along with their values multiplied by 2 and by 10. The data file contains the necessary variable declarations and some output statements.
1. Open the source code file named Multiply.cpp using Notepad or the text editor of your choice.
2. Write a counter-controlled while loop that uses the loop control variable to take on the values 0 through 10. Remember to initialize the loop control variable before the program enters the loop.
3. In the body of the loop, multiply the value of the loop control variable by 2 and by 10. Remember to change the value of the loop control variable in the body of the loop.
4. Save the source code file in a directory of your choice, and then make that directory your working directory.
5. Compile the source code file Multiply.cpp.
6. Execute the program.
Here is the Multiply.cpp file:
Lab 6-1: Array Basics:
Use what you have learned about declaring and initializing arrays to complete the following:
1. Write array declarations for each of the following: a. Six grade point averages. b. Seven last names. c. 10 ages.
2. Declare and initialize arrays that store the following: a. The whole numbers 2, 4, 6, 8, 10 b. The last names Carlson, Matthews, and Cooper c. The prices 15.00, 122.00, and 7.50
3. Write an assignment statement that assigns the value 32 to the first element of the array of integers named customerNumber.
4. An array of ints named numbers is stored at memory location 4000. Where is numbers[1]? Where is numbers[4]?
Here is the BattingAverage.cpp file:
Lab 7-1: Opening files and performing file output:
In this lab, you open a file and read input from that file in a prewritten C++ program. The program should read and print the names of flowers and whether they are grown in shade or sun. The data is stored in the input file named flowers.dat.
1. Open the source code file named Flowers.cpp using Notepad or the text editor of your choice.
2. Declare the variables you will need.
3. Write the C++ statements that will open the input file flowers.dat for reading.
4. Write a while loop to read the input until EOF is reached.
5. In the body of the loop, print the name of each flower and where it can be grown (sun or shade).
6. Save this source code file in a directory of your choice, and then make that directory your working directory.
7. Compile the source code file Flowers.cpp.
8. Execute the program.
Here is the flower.cpp file:
Here is the flowers.dat file:
Astilbe
Shade
Marigold
Sun
Begonia
Sun
Primrose
Shade
Cosmos
Sun
Dahlia
Sun
Geranium
Sun
Foxglove
Shade
Trillium
Shade
Pansy
Sun
Petunia
Sun
Daisy
Sun
Aster
Sun
Explanation / Answer
Multiple Questions : Answering 1st :
// Multiply.cpp - This program prints the numbers 0 through 10 along
// with these values multiplied by 2 and by 10.
// Input: None
// Output: Prints the numbers 0 through 10 along with their values multiplied by 2 and by 10.
#include <iostream>
#include <string>
using namespace std;
int main()
{
string head1 = "Number: ";
string head2 = "Multiplied by 2: ";
string head3 = "Multiplied by 10: ";
int numberCounter; // Numbers 0 through 10
int byTen; // Stores the number multiplied by 10
int byTwo; // Stores the number multiplied by 2
const int NUM_LOOPS = 10; // Constant used to control loop
// This is the work done in the housekeeping() function
cout << "0 through 10 multiplied by 2 and by 10." << endl;
numberCounter = 0;
// This is the work done in the detailLoop() function
// Write while loop here
while(numberCounter<=NUM_LOOPS){
byTen = numberCounter * 10;
byTwo = numberCounter * 2;
cout<<head1<<numberCounter<<" "<<head2<<byTwo<<" "<<head3<<byTen<<endl;
numberCounter++;
}
// This is the work done in the endOfJob() function
return 0;
}// End of main()
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.