Programming Challenge Chapter 3 – Q #6 How Many Widgets? – Tony Gaddis – Starting Out With C++
Problem: -
Solution: -
#include <iostream>
using namespace std;
int main()
{
const float WIDGETS = 9.2;
float pallat_weight, pallat_widgets_itself, total_widgets = 0.0;
float widgets;
cout << "Enter Pallat Wieght
By its Self: ";
cin >> pallat_widgets_itself;
cout << "Enter Pallat Weight
With Widgets: ";
cin >> pallat_weight;
widgets = pallat_weight - pallat_widgets_itself;
total_widgets = widgets / WIDGETS;
cout << "Pallat Weight = " << widgets << endl;
cout << "Number of Widgets
= " << total_widgets << endl;
return 0;
}
This is the solution of this question
OUTPUT OF THIS QUESTION
Input is highlighted with yellow color.
Explanation of this Solution
- Declare float constant and initialize given values.
- Declare three float variables.
- Declare a float variables for calculation.
- Take input from the user by using cin.
- Take input from the user by using cin.
- Calculate widgets and total widgets.
- In last, display output on the screen.
- Return 0 to the main function.
Also, I attach CPP file of this problem. You can download this file
0 Comments