I'm having trouble with making a nested if-else program for my computer programming class, I really need some help with getting the variables set up and I believe I can work it out from there, but as for right now I am stuck.
http://www.uwplatt.edu/csse/courses/CS143/prog1.htmlhere are the guidelines please pm me if you can help! I need to have this done before 10 PM tonight and I can provide some FG is someone is really helpful in getting me going the right direction.
I have some of the code written but I am a complete newbie so it could be all garbage.
Code
//---------------------------------------------------------------------
//
// Name:
//
// Course: CS 1430, Section 2
//
// Purpose: A program that converts between kilometers and miles
// or between Fahrenheit temperature and Celcius.
//
// Input: A character value of 'K' , 'M' , 'F' or 'C'.
// An int or float representing the amount.
//
// Output: A correct conversion between 'K' and 'M' or 'F' and 'C'
// An error message shown for incorrect input of character or
// an error if the temperature or distance is out of range.
//---------------------------------------------------------------------
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;
const float MILES_PER_KM = 1.0f / 1.61f;
const float KM_PER_MILE = 1.61f;
const float FREEZING_F = 32.0f;
const float FAHR_PER_CELSIUS = 9.0f / 5.0f;
const float CELSIUS_PER_FAHR = 5.0f / 9.0f;
const float MAX_F_TEMP = 100.0f;
const float MIN_F_TEMP = 0.0f;
char k = 'K';
char m = 'M';
char f = 'F';
char c = 'C';
float unit;
float amount;
int main()
{
cout << " Input a type (K, M, F, C) : ";
cin >> unit;
cout << " Input an amount : ";
cin >> amount;
if ( unit == 'K' )
{
if ( amount > 0 )
{
cout << " Distance " << amount << " miles is "
<< amount * MILES_PER_KM << " kilometers.";
}
}
return 0;
}
This post was edited by bensfriend1 on Feb 14 2014 07:08pm