Question

In: Computer Science

Program 3.5 - Conversion Program   - NOW using cin statements to gather input from user Concepts...

Program 3.5 - Conversion Program   - NOW using cin statements to gather input from user

Concepts Covered:  Chapter 2 – cout ,   math, data types, Chapter 3 , gathering both numeric & string input from user

Programs 2-21, 2-22, 2-23, 2-28 should help with math and programs 3.5, 3.17 and 3.19 should help you with the new concepts introduced with this program.

Program Purpose:  To help you understand the concept of using both proper numeric variables and string variables. To give you practice using the C++ math operators. To give you practice getting both numeric input and string input from a user. To give you practice overriding the default behavior of C++ for numeric formatting. Lastly, to appreciate the flexibility of the cout object by passing it string variables, string literals, and numeric variables.

Background:  Your instructor is an avid (some would say obsessed) bicyclist.  Rides of 40 to 50 miles are not uncommon. Your instructor also uses an indoor training program called Zwift. It uses the metric system which is kilometers biked (instead of miles), and meters climbed (instead of feet).     You need to help out your metrically challenged professor and write a conversion program that converts kilometers to miles and meters to feet.

For example, if I told some of my non-biking friends that I rode 40 kilometers, many of them would be impressed.  Well, in miles that is only 24.8 miles.   Conversely, if I told them I climbed 1000 meters they may not be impressed.  But, 1000 meters is 3,280 feet which is not too shabby here in the Midwest.

Oh, did I mention, this also applies to runners, especially in terms of kilometers.

  

So your job commission is to write a C++ program which will convert kilometers to miles and meters to feet.

PROGRAM SPECIFICATIONS:

Insert program heading with your name, course, section, program name, AS WELL AS brief documentation of program purpose at the top of your program.

Create your c++ code.

INPUT SECTION

Create 4 numeric variables to hold the following:  meters, feet, kilometers, and miles.

Create 2 string variables: one to hold the activity type:  biking or running and the other to hold a person’s name.

Prompt the user for their name. You should get the user's full name! Example   Jimmy C   or John Bonham

Prompt the user (using their name) for which activity they did. - biking or running

Prompt the user for how many kilometers

Prompt the user for how many meters they climbed

PROCESSING SECTION

Perform the necessary math operations to convert kilometers to miles and meters to feet.

Kilometers to miles formula:

1 kilometer is equal to 0.621371 miles (often shortened to .62). 1 mile is equal to 1.609344 kilometers. Thus, to convert kilometers to miles, simply multiply the number of kilometers by 0.62137.

Meters to feet formula:

Multiply any meter measurement by 3.28 to convert to feet. Since one meter = 3.28 feet, you can convert any meter measurement into feet by multiplying it by 3.28.

1 meter x 3.28 = 3.28 feet

5 meters x 3.28 = 16.4 feet

2.7 meters x 3.28 = 8.856 feet

OUTPUT SECTION

Using cout statements, display the output listing name, activity, kilometers, miles, meters and feet. For formatting of numeric variables, use 2 digits of precision to right of decimal point.with values shown above.

Solutions

Expert Solution

Thanks for the question.


Below is the code you will be needing Let me know if you have any doubts or if you need anything to change.


Thank You !!


===========================================================================

#include<iostream>
#include<iomanip>
#include<string>

using namespace std;


int main(){
  
   double meters, feet , kilometers , miles ;
   string activity_type, person_name;
  
   cout<<"Enter your full name: ";
   getline(cin,person_name);
  
   cout<<"Enter activity type (biking or running): ";
   cin>>activity_type;
  
   cout<<"How many kilometers: "; cin>>kilometers;
   cout<<"How many meters they climbed: "; cin>>meters;
  
  
   miles = kilometers*0.62137;
   feet = meters*3.28;
  
   cout<<"Listing Name: "<<person_name<<endl;
   cout<<"Activity Type: "<<activity_type<<endl;
  
   cout<<fixed<<showpoint<<setprecision(2);
  
   cout<<kilometers<<" km(s)"<<endl
       <<miles<<" miles"<<endl
       <<meters<<" meter(s)"<<endl
       <<feet<<" feet(s)"<<endl;
  
  
}


Related Solutions

create a program using IDLE where you will gather input from the user using a loop....
create a program using IDLE where you will gather input from the user using a loop. The user needs to provide you with a list of test scores for two categories (two different classrooms). Test scores must be integer values between 0 and 10. You need to process each score so that you can output the following: Number of test scores entered for classroom A. Number of test scores entered for classroom B. Average of test scores entered for classroom...
create a program using IDLE where you will gather input from the user using a loop....
create a program using IDLE where you will gather input from the user using a loop. The user needs to provide you with a list of test scores for two categories (two different classrooms). Test scores must be integer values between 0 and 10. You need to process each score so that you can output the following: Number of test scores entered for classroom A. Number of test scores entered for classroom B. Average of test scores entered for classroom...
Question: Conversion Program * This program will ask the user to input meters * After input,...
Question: Conversion Program * This program will ask the user to input meters * After input, a menu will be displayed: * 1. Convert to kilometers * 2. Convert to inches * 3. Convert to feet * 4. Quit * * The user will select the conversion and the converted answer will be displayed. * The program should redisplay the menu for another selection. * Quit program when user selects 4. Hi, my instructor requirement fix the bug in the...
Please write a java program (using dialog box statements for user input) that has the following...
Please write a java program (using dialog box statements for user input) that has the following methods in it: (preferably in order)   a method to read in the name of a University and pass it back a method to read in the number of students enrolled and pass it back a method to calculate the tuition as 20000 times the number of students and pass it back a method print the name of the University, the number of students enrolled,...
Write a program read in data from the standard input stream (cin) representing temperature in Fahrenheit....
Write a program read in data from the standard input stream (cin) representing temperature in Fahrenheit. The program will then convert the values into Kelvin (using 5/9 (Fº-32) to convert to Celsius and a difference of 273.15 between Celsius and Kelvin) and print out the new total value. Convert temperature in Fahrenheit to Kelvin : Enter temperature in Fahrenheit: 80.33 The temperature in Kelvin is: 300 Write a second program which then does the reverse conversion (using a difference of...
Question) The following simple shell program/code using gets() function to obtain input from user. Using the...
Question) The following simple shell program/code using gets() function to obtain input from user. Using the gets() function is potentially dangerous and it allows buffer to overflow. You need to do following modification in the code; (a) change the provided code so that you now use fgets() function instead of fget() to obtain input from the user, (b) make any other necessary changes in the code because of using fgets() function, and (c) fill in the code for the exectute()...
Using C++ Create a program that asks the user to input a string value and then...
Using C++ Create a program that asks the user to input a string value and then outputs the string in the Pig Latin form. - If the string begins with a vowel, add the string "-way" at the end of the string. For “eye”, it will be “eye-way”. - If the string does not begin with a vowel, first add "-" at the end of the string. Then rotate the string one character at a time; that is, move the...
Write Java program that asks a user to input a letter, converts the user input to...
Write Java program that asks a user to input a letter, converts the user input to uppercase if the user types the letter in lowercase, and based on the letter the user the user enters, display a message showing the number that matches the letter entered. For letters A or B or C display 2 For letter D or E or F display 3 For letter G or H or I display 4 For letter J or K or L...
write this program in c++ using iostream library.( cin>>n; cin>> arr[n] and so on) Write a...
write this program in c++ using iostream library.( cin>>n; cin>> arr[n] and so on) Write a function that converts an array so that in the first half settled with elements from odd positions, and in the second half - with elements from the even positions.Positions are counted from the first index.The program have to use pointer. example: input: 7 1 2 3 4 5 6 7 output: 1 3 5 7 2 4 6 8
Hello, I stuck doing c++ program The program will be recieved from the user as input...
Hello, I stuck doing c++ program The program will be recieved from the user as input name of an input file and and output.file. then read in a list of name, id# and score from input file (inputFile.txt) and initilized the array of struct. find the student with the higher score and output the students info in the output file obtain the sum of all score and output the resurl in output file. prompt the user for a name to...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT