Ce diaporama a bien été signalé.
Le téléchargement de votre SlideShare est en cours. ×

# Please write the solution in the c++ language Write a program that rea.docx

Publicité
Publicité
Publicité
Publicité
Publicité
Publicité
Publicité
Publicité
Publicité
Publicité
Publicité
Chargement dans…3
×

## Consultez-les par la suite

1 sur 2 Publicité

# Please write the solution in the c++ language Write a program that rea.docx

Please write the solution in the c++ language
Write a program that reads six wall lengths, one room height, and prints out the total wall area. Useful for determining how much paint to buy to cover a room, or how much building materials to buy.
+-----+
|Â Â Â Â  |
|Â Â  +-+
|Â Â  |
+---+
Solution
#include <iostream>
using namespace std;
int main() {
int walls[6];
int height;
int total=0;
for(int i=0;i<6;i++)
{
cout<<\"\ Enter Wall \"<<i+1<<\" length: \";
cin>>walls[i];
}
cout<<\"\ Enter Room Height: \";
cin>>height;
cout<<\"\ \";
for(int i=0;i<6;i++)
{
cout<<\"\ Area of Wall \"<<i+1<<\" is: \"<<walls[i]*height;
total+=walls[i]*height;
}
cout<<\"\ \ Total Area is: \"<<total;

return 0;
}
output:
Enter Wall 1 length: 10
Enter Wall 2 length: 20
Enter Wall 3 length: 10
Enter Wall 4 length: 20
Enter Wall 5 length: 30
Enter Wall 6 length: 20
Enter Room Height: 20
Area of Wall 1 is: 200
Area of Wall 2 is: 400
Area of Wall 3 is: 200
Area of Wall 4 is: 400
Area of Wall 5 is: 600
Area of Wall 6 is: 400
Total Area is: 2200
RUN SUCCESSFUL (total time: 13s)
.

Please write the solution in the c++ language
Write a program that reads six wall lengths, one room height, and prints out the total wall area. Useful for determining how much paint to buy to cover a room, or how much building materials to buy.
+-----+
|Â Â Â Â  |
|Â Â  +-+
|Â Â  |
+---+
Solution
#include <iostream>
using namespace std;
int main() {
int walls[6];
int height;
int total=0;
for(int i=0;i<6;i++)
{
cout<<\"\ Enter Wall \"<<i+1<<\" length: \";
cin>>walls[i];
}
cout<<\"\ Enter Room Height: \";
cin>>height;
cout<<\"\ \";
for(int i=0;i<6;i++)
{
cout<<\"\ Area of Wall \"<<i+1<<\" is: \"<<walls[i]*height;
total+=walls[i]*height;
}
cout<<\"\ \ Total Area is: \"<<total;

return 0;
}
output:
Enter Wall 1 length: 10
Enter Wall 2 length: 20
Enter Wall 3 length: 10
Enter Wall 4 length: 20
Enter Wall 5 length: 30
Enter Wall 6 length: 20
Enter Room Height: 20
Area of Wall 1 is: 200
Area of Wall 2 is: 400
Area of Wall 3 is: 200
Area of Wall 4 is: 400
Area of Wall 5 is: 600
Area of Wall 6 is: 400
Total Area is: 2200
RUN SUCCESSFUL (total time: 13s)
.

Publicité
Publicité

## Plus De Contenu Connexe

Publicité

### Please write the solution in the c++ language Write a program that rea.docx

1. 1. Please write the solution in the c++ language Write a program that reads six wall lengths, one room height, and prints out the total wall area. Useful for determining how much paint to buy to cover a room, or how much building materials to buy. +-----+ |Â Â Â Â | |Â Â +-+ |Â Â | +---+ Solution #include <iostream> using namespace std; int main() { int walls[6]; int height; int total=0; for(int i=0;i<6;i++) { cout<<" Enter Wall "<<i+1<<" length: "; cin>>walls[i]; } cout<<" Enter Room Height: "; cin>>height; cout<<" "; for(int i=0;i<6;i++) { cout<<" Area of Wall "<<i+1<<" is: "<<walls[i]*height; total+=walls[i]*height; } cout<<" Total Area is: "<<total;
2. 2. return 0; } output: Enter Wall 1 length: 10 Enter Wall 2 length: 20 Enter Wall 3 length: 10 Enter Wall 4 length: 20 Enter Wall 5 length: 30 Enter Wall 6 length: 20 Enter Room Height: 20 Area of Wall 1 is: 200 Area of Wall 2 is: 400 Area of Wall 3 is: 200 Area of Wall 4 is: 400 Area of Wall 5 is: 600 Area of Wall 6 is: 400 Total Area is: 2200 RUN SUCCESSFUL (total time: 13s)