217k views
3 votes
2.3 Code Practice: Question 2

Instructions
Write a program that inputs the length of two pieces of fabric in feet and
inches (as whole numbers) and prints the total.

Sample Run
Enter the Feet: 3
Enter the Inches: 11
Enter the Feet: 2
Enter the Inches: 5
Sample Output
Feet: 6 Inches: 4

1 Answer

1 vote

Answer:

Using C++

#include<iostream>

using namespace std;

int main()

{

int F1,F2,I1,I2,feet,inches;

cout<<"Enter the Feet: "; cin>>F1;

//----------------------------------------------

cout<<"Enter the Inches: "; cin>>I1;

//----------------------------------------------

cout<<"Enter the Feet: "; cin>>F2;

//----------------------------------------------

cout<<"Enter the Inches: "; cin>>I2;

//----------------------------------------------

feet = F1 + F2 + (I1 + I2) / 12;

inches = (I1 + I2) % 12;

cout<<"Feet: "<<feet<<" Inches: "<<inches<<endl;

return 0;

}

Step-by-step explanation:

User Nabat Farsi
by
4.4k points