Levels Tought:
Elementary,Middle School,High School,College,University,PHD
Teaching Since: | Jul 2017 |
Last Sign in: | 210 Weeks Ago, 3 Days Ago |
Questions Answered: | 15833 |
Tutorials Posted: | 15827 |
MBA,PHD, Juris Doctor
Strayer,Devery,Harvard University
Mar-1995 - Mar-2002
Manager Planning
WalMart
Mar-2001 - Feb-2009
I am trying to build this program for C++, I c/*--------------------------------------------------------
// AUTHOR: Katharine Geiger
// FILENAME: Lab2.cpp
// SPECIFICATION: Program is used for practicing getline,
                 expressions, conversions and fixed,
                 setprecision, and setw functions.
// FOR: CSE 100- Lab #2
// TIME SPENT: 3 hours
//-------------------------------------------------------*/
#include <iostream>
#include <iomanip>
#include <string>Â // required to perform string commands
using namespace std;
int main()
{
   // processes below define variables;
   double KM_PER_MILE = 1.60935;
   double MIN_PER_HOUR = 60.0;
   string firstName;
   string lastName;
   double randomDouble;
   // Section One: Inputting First and Last Name variables utilizing getline commands
   cout << "Please enter your first name: "; //outputs first name propmpt and input of first name variable;
   getline (cin, firstName);
   cout << "Please enter your last name: "; //outputs last name prompt and input of last name variable;
   getline (cin, lastName);
   cout << firstName <<" " << lastName<< endl; //displays first name and last name inputs
   // Section Two: Inputting, holding variables, and calculations of time and distance.
   int distance; // declaration of input variable for distance
   cout << "Please enter the distance traveled in miles:\n"; cin >> distance; // output of distance traveled prompt and input of variable;
   int time; // declaration of input variable for time
   cout << "Enter the time traveled in minutes:\n"; cin >> time; // output of time traveled prompt and input of variable;
   double timeInHours = time / MIN_PER_HOUR; // defines the parameters for timeInHours
   double milesPerHour = distance / timeInHours; // defines the parameters for milesPerHour
   double kmPerHour = milesPerHour * KM_PER_HOUR; // defines the parameters for kmPerHour
   cout << "Miles per hour:\n "; double >> milesPerHour ; << setw 13; // outputs prompt and defines the width for milesPerHour input.
   cout << fixed << setprecision (2); // sets decimal places to two spots after decimal point.
   cout << "km per hour:\n "; double >> kmPerHour; << setw 13; // outputs prompt and defines the width for kmPerHour input.
   // Section Three: incorporation of the randomDouble, setw, and setprecision variables continued.
   cout << "Please enter a random number with 3 digits before and 4 digits after the decimal point:\n"; cin >> randomDouble;
   cout << fixed << setprecision (3); // sets decimal places to three spots after decimal point.
   cout << randomDouble; << setw 11 << endl; //sets the width for the randomDouble input
   cout << cin >> randomDouble;
   return 0;
}
annot for the life of me figure out where I am going wrong, any help would be greatly appreciated.
----------- Â ----------- H-----------ell-----------o S-----------ir/-----------Mad-----------am ----------- Th-----------ank----------- yo-----------u f-----------or -----------you-----------r i-----------nte-----------res-----------t a-----------nd -----------buy-----------ing----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n. -----------Ple-----------ase----------- pi-----------ng -----------me -----------on -----------cha-----------t I----------- am----------- on-----------lin-----------e o-----------r i-----------nbo-----------x m-----------e a----------- me-----------ssa-----------ge -----------I w-----------ill----------- be----------- qu-----------ick-----------ly