Created
September 17, 2019 23:14
-
-
Save mariaturtles/5228d321547701a9a58422f7050ca7df to your computer and use it in GitHub Desktop.
Programming Exercise 3-3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*Instructions | |
Write a program that prompts the user to enter the weight of a person in kilograms | |
and outputs the equivalent weight in pounds (Note that 1 kilogram equals 2.2 pounds). | |
Format your output with two decimal places. *\ | |
#include <iostream> | |
#include <iomanip> | |
using namespace std; | |
//Declare named constant to converts kilograms to pounds | |
const double POUNDS =2.2; | |
int main() | |
{ | |
//Declare varibles | |
double weightInKilograms; | |
double weightInPounds; | |
//Read user input | |
cout<<"Enter Weight in kilograms :\n"; | |
cin>>weightInKilograms; | |
//Convert kilograms to pounds | |
weightInPounds = weightInKilograms * POUNDS; | |
//Set fixed and precistion to 2 , display output in two decimal places | |
cout<<fixed<<setprecision(2); | |
//Display weightInPounds | |
cout<<"Weight in Pounds is : "<<weightInPounds<<endl; | |
return 0; | |
} |
@Aklile1212 you ruined it for everyone. All my programming codes are getting locked. "Do these problems?" Wtf bossy ass
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Please complete the following two coding assignments.
Weight Conversion problem - Write a program the prompts the user to enter the weight of a person in kilograms and output the equivalent weight in pounds. Output both the weights rounded to two decimal places (note that 1 kilogram equals 2.2 lbs.). format your output with two decimal places. Save this problem as CIT-100-
Logic Errors -During each summer, John and Jessica grow vegetables in their backyard and buy seeds and fertilizer from a local Nursery. The nursery carries different types of vegetable fertilizers in various bag sizes. When buying a particular fertilizer, they want to know the price of the fertilizer per pound and the cost of fertilizing per square foot. The following program prompts the user to enter the size of the fertilizer bag, in pounds, the cost of the bag, and the area, in square feet, that can be covered by the bag. The program should output the desired result. However, the program contains logic errors. Find and correct the logic errors so that the program works properly. The program is pre-written and is attached.