I'm using C#. I am trying to allow the user to input a numerical value (IE: how many do you want?) and then take that value and figure tax and total. I can not figure out how to do this and wondered if anyone could show me? My current script is below:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Welcome to Infinate Happiness Ranch.\nPlease enter your order information bellow. ");
Console.WriteLine();
Console.WriteLine("Please enter your first and last name:");
string FirstName = Console.ReadLine();
Console.WriteLine("Please enter your street address:");
string Address = Console.ReadLine();
Console.WriteLine("Please enter your city:");
string City = Console.ReadLine();
Console.WriteLine("Please enter your two letter state abbreviation:");
string StateCode = Console.ReadLine();
Console.WriteLine("Please enter your zip code:");
string ZipCode = Console.ReadLine();
Console.WriteLine("Please enter the number of Tribbles \nyou wish to purchase for $29.99 plus tax");
string NumberOrdered = Console.ReadLine();
Console.WriteLine("Invoice \nName {0}", FirstName);
Console.WriteLine("Address {0}", Address);
Console.WriteLine("City {0}", City);
Console.WriteLine("StateCode {0}", StateCode);
Console.WriteLine("ZipCode {0}", ZipCode);
Console.WriteLine("NumberOrdered {0}", NumberOrdered);
// PROGRAM WORKS UNTIL HERE.
NumberOrdered = m;
TotalBeforeTax = m * 29.99; //'n' is total b4 tax
o = n * 0.9;// 'o' is total tax due
p = o + n; // 'p' is total due
Console.WriteLine("Your total is {0} {1}", n);
Console.WriteLine("Your tax is {0}", o);
Console.WriteLine("Your total charge is {0}", p);
Console.WriteLine("Thank you for your order");
Console.WriteLine();
//Console.WriteLine("Name:" + FirstName);
Console.Read();
}
}
}
You should parse the string with
int ordered = int.Parse(NumberOrdered);
And continue to calculate with this integer.
Because the user is entering information as strings, you should convert the number ordered to an integer. Also, to preserve your decimals, you need to store numbers as doubles for things such amounts.
int numOrdered = Convert.ToInt32(NumberOrdered);
double TotalBeforeTax = numOrdered * 29.99;
double beforeTax = TotalBeforeTax * 0.9;
double afterTax = beforeTax + TotalBeforeTax;
Console.WriteLine("Your total is {0}", TotalBeforeTax);
Console.WriteLine("Your tax is {0}", beforeTax);
Console.WriteLine("Your total charge is {0}", afterTax);
Console.WriteLine("Thank you for your order");
You forgot to declare some variables and assign some values.
Try this:
static float m;
static float n;
static float o;
static float p;
static float TotalBeforeTax;
static void Main(string[] args)
{
Console.WriteLine("Welcome to Infinate Happiness Ranch.\nPlease enter your order information bellow. ");
Console.WriteLine();
Console.WriteLine("Please enter your first and last name:");
string FirstName = Console.ReadLine();
Console.WriteLine("Please enter your street address:");
string Address = Console.ReadLine();
Console.WriteLine("Please enter your city:");
string City = Console.ReadLine();
Console.WriteLine("Please enter your two letter state abreviation:");
string StateCode = Console.ReadLine();
Console.WriteLine("Please enter your zip code:");
string ZipCode = Console.ReadLine();
Console.WriteLine("Please enter the number of Tribbles \nyou wish to purchase for $29.99 plus tax");
string NumberOrdered = Console.ReadLine();
Console.WriteLine("Invoice \nName {0}", FirstName);
Console.WriteLine("Address {0}", Address);
Console.WriteLine("City {0}", City);
Console.WriteLine("StateCode {0}", StateCode);
Console.WriteLine("ZipCode {0}", ZipCode);
Console.WriteLine("NumberOrdered {0}", NumberOrdered);
//PROGRAM WORKS UNTIL HERE ? HELP ? ? ? ? ?
//NumberOrdered = m;
m = float.Parse(NumberOrdered);
TotalBeforeTax = m * 29.99f; //'n' is total b4 tax
n = TotalBeforeTax;
o = n * 0.9f;//'o' is total tax due
p = o + n; //'p' is total due
Console.WriteLine("Your total is {0}", n);
Console.WriteLine("Your tax is {0}", o);
Console.WriteLine("Your total charge is {0}", p);
Console.WriteLine("Thank you for your order");
Console.WriteLine();
Console.Read();
}
Hope this helps !
Just a bit of advice, you can include non-string variables in Console.WriteLine() like:
Console.WriteLine("Your tax is " + o);
This is what most professional developers do. No need for complicated C/C++ style of parsing.
Also, you don't seem to be declaring the variables o and p. Try this:
double o = Convert.toDouble(n * 0.9);
or
double o = (double)(n * 0.9);
Related
I don't know the codes as I'm a beginner in c#, so could anyone help me with these? I want my pin to enter in 4 digits only and re verified the pin to continue in the menu?
{
class program
{
public static void Main()
{
int amount = 1000, deposit, withdraw;
int choice, pin = 0, x = 0;
Console.WriteLine("Enter Your Pin Number ");
pin = int.Parse(Console.ReadLine());
while (true)
{
Console.WriteLine("********Welcome to ATM Service**************\n");
Console.WriteLine("1. Check Balance\n");
Console.WriteLine("2. Withdraw Cash\n");
Console.WriteLine("3. Deposit Cash\n");
Console.WriteLine("4. Quit\n");
Console.WriteLine("*********************************************\n\n");
Console.WriteLine("Enter your choice: ");
choice = int.Parse(Console.ReadLine());
switch (choice)
{
case 1:
Console.WriteLine("\n YOUR BALANCE IN Rs : {0} ", amount);
break;
case 2:
Console.WriteLine("\n ENTER THE AMOUNT TO WITHDRAW: ");
withdraw = int.Parse(Console.ReadLine());
if (withdraw % 100 != 0)
{
Console.WriteLine("\n PLEASE ENTER THE AMOUNT IN MULTIPLES OF 100");
}
else if (withdraw > (amount - 500))
{
Console.WriteLine("\n INSUFFICENT BALANCE");
}
else
{
amount = amount - withdraw;
Console.WriteLine("\n\n PLEASE COLLECT CASH");
Console.WriteLine("\n YOUR CURRENT BALANCE IS {0}", amount);
}
break;
case 3:
Console.WriteLine("\n ENTER THE AMOUNT TO DEPOSIT");
deposit = int.Parse(Console.ReadLine());
amount = amount + deposit;
Console.WriteLine("YOUR BALANCE IS {0}", amount);
break;
case 4:
Console.WriteLine("\n THANK U USING ATM");
break;
}
}
Console.WriteLine("\n\n THANKS FOR USING OUT ATM SERVICE");
}
}
}
I suggest something like this:
// read size (4) digits
private static string ReadPin(int size = 4) {
StringBuilder sb = new StringBuilder(size);
while (sb.Length < size) {
var key = Console.ReadKey(true); // we don't want to show the secret pin on the screen
// Uncomment, if you want to let user escape entering the PIN
// if (key.Key == ConsoleKey.Escape) {
// return "";
// }
if (key.KeyChar >= '0' && key.KeyChar <= '9') {
sb.Append(key.KeyChar);
Console.Write('*'); // let's show * instead of actual digit
}
}
return sb.ToString();
}
...
// private: there's no need for Main to be public
private static void Main() {
...
Console.WriteLine("Enter Your Pin Number ");
int pin = int.Parse(ReadPin());
If you want to verify the given string (pin) which is expected to be of length size, you can try either Linq
using System.Linq;
...
string pin = ...
int size = 4;
bool isValidPin = pin.Length == size && pin.All(c => c >= '0' && c <= '9');
Or regular expressions:
using System.Text.RegularExpressions;
...
bool isValidPin = Regex.IsMatch(pin, $"^[0-9]{{{size}}}$");
int password;
int repassword
Do{
Console.WriteLine("\n Enter the password");
password= int.Parse(Console.ReadLine()); //first password
string ps = Convert.ToString(password);
}while(ps.Length!=4) //request the password if is not composed by 4 digits
//menu part//
Do{
Console.WriteLine("\n Reinsert the password");
repassword= int.Parse(Console.ReadLine()); //reinsert password
} while(repassword!=password)
I need help with some of my code for a game calculator. So I wrote all this code, but the IF/THEN statement is acting weird.
Screenshot:
-
I typed in P and it should have gone to the ELSE part of the code, but instead it continued onto the if part. Please help!
{
class MainClass
{
public static void Main(string[] args) // IF YOU ARE TO REWRITE FROM MY SOURCE, ALL ORIGINAL CREDITORS MUST GO INTO THE CREDITS!
{
double num01;
double num02;
double num03;
double num04;
double num05;
double num06;
string CD = null;
string P = null;
string answer = null;
Console.Write("Diogenes's Calculator 1.0\n\nCredits: DoS (#57714)\n DZ(#54689)");
Console.WriteLine();
Console.WriteLine();
Console.Write("Hello! Would you like Charity Donation or Propaganda Calculator? (CD or P): ");
Console.ReadLine();
answer = Convert.ToString();
if(answer == CD) {
Console.WriteLine();
Console.Write("Howmuch influence does the target have?: ");
num01 = Convert.ToDouble(Console.ReadLine());
Console.Write("Howmuch is the cost of Charity Donatins? (Gold): ");
num02 = Convert.ToDouble(Console.ReadLine());
Console.Write("What % of influence does Charity Donation give (Made if value does change)?: ");
num03 = Convert.ToDouble(Console.ReadLine());
Console.Write(num02 + num03);
Console.ReadKey();
} else if(answer == P) {
answer = Convert.ToString();
Console.WriteLine();
Console.Write("Howmuch influence does the target have?: ");
num04 = Convert.ToDouble(Console.ReadLine());
Console.Write("Howmuch influence do you want the target to have?: ");
num05 = Convert.ToDouble(Console.ReadLine());
Console.Write("What % of influence does Propaganda take off (Made if value does change)?: ");
num06 = Convert.ToDouble(Console.ReadLine());
Console.Write(num04 + num05);
Console.ReadKey();
} else {
Console.WriteLine("Looks like you didn't type in CD or P. Buh Bye!");
Console.ReadKey();
}
}
}
}
you are checking if answer is equal to the value stored in the field P, not if answer is equal to the actual string "P". And P the variable is null.
Secondly, you are throwing away your user input here:
Console.ReadLine();
answer = Convert.ToString();
you are reading the console input into nothing, then assigning answer to the Convert object's string representation, which is probably a fully qualified namespace. You want:
answer = Console.ReadLine();
Console.Write("Hello! Would you like Charity Donation or Propaganda Calculator? (CD or P): ");
answer = Console.ReadLine();
if(answer == "CD") {
I need some help making sure that when the user enters nothing, or not a number, it doesn't crash. I have it down so that it will tell them to enter a number if they don't, but I don't know how to make it go back to the original question and give them a chance to input correctly. Thanks for the help.
Console.WriteLine("How much is rent: ");
string strRent = Console.ReadLine();
double dblRent = 0.0;
if (double.TryParse(strRent, out dblRent))
{
Console.WriteLine("How much is the car payment: ");
string strCarPayment = Console.ReadLine();
double dblCarPayment = Convert.ToDouble(strCarPayment);
}
else
{
Console.WriteLine("Enter a number");
}
Console.WriteLine("How much is student loan payment: ");
string strStudentLoan = Console.ReadLine();
Console.WriteLine("How much is phone bill: ");
string strPhoneBill = Console.ReadLine();
Console.WriteLine("How much is electric bill: ");
string strElectricBill = Console.ReadLine();
Console.WriteLine("Fraction deposited: ");
string strFractionDeposited = Console.ReadLine();
Console.WriteLine("Amount leftover: ");
string strAmountLeft = Console.ReadLine();
double dblStudentLoan = Convert.ToDouble(strStudentLoan);
double dblPhoneBill = Convert.ToDouble(strPhoneBill);
double dblElectricBill = Convert.ToDouble(strElectricBill);
double dblFractionDeposited = Convert.ToDouble(strFractionDeposited);
double dblAmountLeft = Convert.ToDouble(strAmountLeft);
double dblBillSum = dblRent + dblCarPayment + dblStudentLoan + dblPhoneBill + dblElectricBill;
double afterBills = dblAmountLeft / (1 - dblFractionDeposited);
double totalPaycheck = afterBills + dblBillSum;
Console.WriteLine("Total Paycheck: " + totalPaycheck.ToString("C"));
Console.WriteLine("Enter wage $/hr: ");
string strWage = Console.ReadLine();
Console.WriteLine("Enter hours worked overtime: ");
string strHoursOT = Console.ReadLine();
Console.WriteLine("Enter overtime multiplier: ");
string strOTWage = Console.ReadLine();
double dblWage = Convert.ToDouble(strWage);
double dblHoursOT = Convert.ToDouble(strHoursOT);
double dblOTWage = Convert.ToDouble(strOTWage);
double OTPay = (dblWage * dblOTWage) * dblHoursOT;
Console.WriteLine("Overtime Pay: " + OTPay.ToString("C"));
Console.ReadLine();
}
}
}
You need a loop, something like this
Console.WriteLine("How much is rent: ");
string strRent = Console.ReadLine();
double dblRent = 0.0;
while (!double.TryParse(strRent, out dblRent))
{
Console.WriteLine("Enter a number");
strRent = Console.ReadLine();
}
Console.WriteLine("How much is the car payment: ");
string strCarPayment = Console.ReadLine();
double dblCarPayment = Convert.ToDouble(strCarPayment);
Try this
double dblRent = 0.0;
Boolean valid = false;
while (!valid)
{
if (double.TryParse(strRent, out dblRent))
{
Console.WriteLine("How much is the car payment: ");
string strCarPayment = Console.ReadLine();
double dblCarPayment = Convert.ToDouble(strCarPayment);
valid = true;
}
else
{
Console.WriteLine("Enter a number");
}
}
Since you are reading many doubles, you could create a method encapsulating reading and processing the number
private static double? ReadLineDouble()
{
while(true) {
string s = Console.ReadLine();
if (String.IsNullOrWhitespace(s)) {
return null; // The user wants to abort
}
double d;
if (Double.TryParse(s, out d)) {
return d;
}
Console.WriteLine("Please enter a valid number");
}
}
If the user just hits Enter probably he wants to abort. In this case the method returns null. This is possible, because the return type is a Nullable<double>. The shorthand notation for it is double?.
Now you can read a number like this:
double? rent = ReadLineDouble();
if (double == null) return; // Abort the program.
// Otherwise continue.
I am trying to create a program for a hotel where the user is to enter a character (either S, D, or L) and that is supposed to correspond with a code further down the line. I need help converting the user input (no matter what way they enter it) to be converted to uppercase so I can then use an if statement to do what I need to do.
My code so far is the following:
public static void Main()
{
int numdays;
double total = 0.0;
char roomtype, Continue;
Console.WriteLine("Welcome to checkout. We hope you enjoyed your stay!");
do
{
Console.Write("Please enter the number of days you stayed: ");
numdays = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("S = Single, D = Double, L = Luxery");
Console.Write("Please enter the type of room you stayed in: ");
roomtype = Convert.ToChar(Console.ReadLine());
**^Right Her is Where I Want To Convert To Uppercase^**
total = RoomCharge(numdays,roomtype);
Console.WriteLine("Thank you for staying at our motel. Your total is: {0}", total);
Console.Write("Do you want to process another payment? Y/N? : ");
Continue = Convert.ToChar(Console.ReadLine());
} while (Continue != 'N');
Console.WriteLine("Press any key to end");
Console.ReadKey();
}
public static double RoomCharge(int NumDays, char RoomType)
{
double Charge = 0;
if (RoomType =='S')
Charge = NumDays * 80.00;
if (RoomType =='D')
Charge= NumDays * 125.00;
if (RoomType =='L')
Charge = NumDays * 160.00;
Charge = Charge * (double)NumDays;
Charge = Charge * 1.13;
return Charge;
}
Try default ToUpper method.
roomtype = Char.ToUpper(roomtype);
Go through this http://msdn.microsoft.com/en-us/library/7d723h14%28v=vs.110%29.aspx
roomtype = Char.ToUpper(roomtype);
public static void Main()
{
int numdays;
double total = 0.0;
char roomtype, Continue;
Console.WriteLine("Welcome to checkout. We hope you enjoyed your stay!");
do
{
Console.Write("Please enter the number of days you stayed: ");
numdays = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("S = Single, D = Double, L = Luxery");
Console.Write("Please enter the type of room you stayed in: ");
roomtype = Convert.ToChar(Console.ReadLine());
roomtype = Char.ToUpper(roomtype);
total = RoomCharge(numdays,roomtype);
Console.WriteLine("Thank you for staying at our motel. Your total is: {0}", total);
Console.Write("Do you want to process another payment? Y/N? : ");
Continue = Convert.ToChar(Console.ReadLine());
} while (Continue != 'N');
Console.WriteLine("Press any key to end");
Console.ReadKey();
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConTempConversion_LeeMichelle
{
class Program
{
static void Main(string[] args)
{
double fTemp;
double cTemp;
double convertC;
double convertF;
Console.WriteLine("Welcome to the temperature conversion application");
Console.WriteLine("_________________________________________________");
Console.WriteLine("1. Fahrenheit to Celsius");
Console.WriteLine("2. Celsius to Fahrenheit");
Console.WriteLine("3. Exit");
Console.Write("Enter choice: ");
Console.ReadKey();
int ichoice = 0;
do
{
if (ichoice == 1)
{
Console.WriteLine("Enter Fahrenheit temperature: ");
fTemp = int.Parse(Console.ReadLine());
convertC = ConvertCelcius(fTemp);
Console.WriteLine(fTemp + "Fahrenheit is " + convertC + "Celsius");
Console.WriteLine("Welcome to the temperature conversion application");
Console.WriteLine("_________________________________________________");
Console.ReadKey();
}
if (ichoice == 2)
{
Console.WriteLine("Enter Celsius temperature: ");
cTemp = int.Parse(Console.ReadLine());
convertF = ConvertFahrenheit(cTemp);
Console.WriteLine(cTemp + "Celsius is " + convertF + "Fahrenheit");
Console.WriteLine("Welcome to the temperature conversion application");
Console.WriteLine("____________________________________________________");
Console.ReadKey();
}
if (ichoice == 3)
{
Console.WriteLine("Thank you for using the temperature conversion application. Please come again.");
}
else
{
Console.WriteLine("Invalid choice. Please choose again!");
}
}
while (ichoice > 3);
Console.ReadKey();
}
static double ConvertCelcius(double c){
double f;
return f= 9.0 / 5.0 * c + 32;
}
static double ConvertFahrenheit(double f) {
double c;
return c = 5.0 / 9.0 * (f - 32);
}
}
}
so suppose the user has three options from 1 - 3. After option 3, there will be an error alert. my problem is why this code gives me an infinity loop? what did I do wrong? can I put break after each if statment?
Please help, thank you!
You're creating a do...while loop without anything to ever exit it. When the loop begins, ichoice is already set in stone. So you'll always be stuck in that loop!
You are never assigning a value to ichoice If I were you, I would try something like this:
int ichoice = 0;
int.TryParse(Console.ReadKey().ToString(), out ichoice );
do
{
if (ichoice == 1)
{
Console.WriteLine("Enter Fahrenheit temperature: ");
fTemp = int.Parse(Console.ReadLine());
convertC = ConvertCelcius(fTemp);
Console.WriteLine(fTemp + "Fahrenheit is " + convertC + "Celsius");
Console.WriteLine("Welcome to the temperature conversion application");
Console.WriteLine("_________________________________________________");
int.TryParse(Console.ReadKey().ToString(), out ichoice );
Add the int.TryParse(Console.ReadKey().ToString(), out ichoice ); everywhere you have Console.Readline(). What this is doing is getting the user input and converting it to an integer (if it's not an integer, then the value is 0).
Also add this:
if (ichoice == 3)
{
Console.WriteLine("Thank you for using the temperature conversion application. Please come again.");
break;
}
else
{
Console.WriteLine("Invalid choice. Please choose again!");
int.TryParse(Console.ReadKey().ToString(), out ichoice );
}
Finally, remove this (I'm not quite sure what it was for...)
while (ichoice > 3);
Console.ReadKey();
When you need to do some prep work before your condition, the most straightforward way involves combining your loop with a separate structure.
This is the format to use when your loop condition is at the beginning of the loop:
prep work
while (condition) // if false then loop body will never run
{
loop body
}
This is the format to use when the loop condition is at the end of the loop:
prep work
do
{
loop body
}
while (condition); // loop body will always execute at least once
In this case, you have some prep work to do before each iteration--you want to get the key press from the user each time. For this, I recommend the following from Code Complete:
while (true) // loop termination condition is inside the loop
{
prep work
if (condition)
{
break;
}
loop body
}
In your case, it would look something like:
Console.Write("Enter choice: ");
while (true) // loop termination condition is inside the loop
{
Console.ReadKey();
if (ichoice == 3)
{
Console.WriteLine(...);
break;
}
...
}
Also, consider changing most of your ifs into else ifs; otherwise, you're repeatedly checking the condition even when you've gone through one case.
you should assign a value to iChoice. and set your while to read a terminating character. like:
namespace YourNameSpace
{
static void Main(string[] args)
{
double fTemp;
double cTemp;
double convertC;
double convertF;
int iChoice;
Console.WriteLine("Welcome to the temperature conversion application");
Console.WriteLine("_________________________________________________");
Console.WriteLine("1. Fahrenheit to Celsius");
Console.WriteLine("2. Celsius to Fahrenheit");
Console.Write("Enter choice(0 to exit): ");
iChoice = Console.Read();
do{
switch(iChoice)
{
case 1:
Console.WriteLine("Enter Fahrenheit temperature: ");
fTemp = int.Parse(Console.ReadLine());
convertC = ConvertCelcius(fTemp);
Console.WriteLine(fTemp + "Fahrenheit is " + convertC + "Celsius");
case 2:
Console.WriteLine("Enter Celsius temperature: ");
cTemp = int.Parse(Console.ReadLine());
convertF = ConvertFahrenheit(cTemp);
Console.WriteLine(cTemp + "Celsius is " + convertF + "Fahrenheit");
}
Console.WriteLine("Welcome to the temperature conversion application");
Console.WriteLine("_________________________________________________");
Console.WriteLine("1. Fahrenheit to Celsius");
Console.WriteLine("2. Celsius to Fahrenheit");
Console.Write("Enter choice(0 to exit): ");
iChoice = Console.Read();
}while(iChoice != 0);
}
static double ConvertCelcius(double c){
double f;
return f= 9.0 / 5.0 * c + 32;
}
static double ConvertFahrenheit(double f) {
double c;
return c = 5.0 / 9.0 * (f - 32);
}
}
Each time you call Console.ReadKey you should store returning value.You are receiving input from user but you didn't store it anywhere.
First you can create a function to get ichoice, and force user to enter the correct value:
static void GetChoice(ref int ichoice)
{
string input = Console.ReadLine();
Console.Write("Enter choice: ");
bool result = int.TryParse(input, out ichoice);
if (!result)
{
while (!result && ichoice > 3)
{
Console.WriteLine("Invalid value.Try again:");
input = Console.ReadLine();
result = int.TryParse(input, out ichoice);
}
}
}
Then use this function whenever you need to make a choice.
Here is the working version or your program:
double fTemp;
double cTemp;
double convertC;
double convertF;
Console.WriteLine("Welcome to the temperature conversion application");
Console.WriteLine("_________________________________________________");
Console.WriteLine("1. Fahrenheit to Celsius");
Console.WriteLine("2. Celsius to Fahrenheit");
Console.WriteLine("3. Exit");
int ichoice = 0;
GetChoice(ref ichoice);
do
{
if (ichoice == 1)
{
Console.WriteLine("Enter Fahrenheit temperature: ");
fTemp = int.Parse(Console.ReadLine());
convertC = ConvertCelcius(fTemp);
Console.WriteLine(fTemp + "Fahrenheit is " + convertC + "Celsius");
Console.WriteLine("Welcome to the temperature conversion application");
Console.WriteLine("_________________________________________________");
GetChoice(ref ichoice);
}
if (ichoice == 2)
{
Console.WriteLine("Enter Celsius temperature: ");
cTemp = int.Parse(Console.ReadLine());
Console.WriteLine(cTemp + "Celsius is " + cTemp + "Fahrenheit");
Console.WriteLine("Welcome to the temperature conversion application");
Console.WriteLine("____________________________________________________");
GetChoice(ref ichoice);
}
if (ichoice == 3)
{
Console.WriteLine("Thank you for using the temperature conversion application. Please come again.");
}
else
{
Console.WriteLine("Invalid choice. Please choose again!");
}
}
while (ichoice < 3);
}
static double ConvertCelcius(double c)
{
double f;
return f = 9.0 / 5.0 * c + 32;
}
static double ConvertFahrenheit(double f)
{
double c;
return c = 5.0 / 9.0 * (f - 32);
}
And here is the full code: http://pastebin.com/bkegSAFL