473,326 Members | 2,175 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Input string not correct format

What am I doing wrong here?

using System;

namespace SchoolStuff
{

class BodyFat
{
public static void Main()
{
const double kiloToPound = 2.2046, inchToMeter = 39.370;
double weight, height;
double kilograms, meters;
Console.WriteLine("Please enter your name");
string name = Console.ReadLine();
Console.WriteLine("Thank you "+ name);
Console.WriteLine("Enter weight in pounds:");
string data = Console.ReadLine();
weight = double.Parse(data);
kilograms = weight / kiloToPound;
Console.WriteLine("\nThis is approximately {0:F2} kg.", kilograms);

Console.WriteLine("\nEnter height in inches:");
data = Console.ReadLine();
height = double.Parse(data);
meters = height / inchToMeter;
double bmi;
bmi = kilograms / (meters * meters);
Console.WriteLine("\nYour BMI is approximately {0:F2}.", bmi);

if (bmi == 25)
Console.WriteLine("25 is average.");
else if (bmi < 25)
Console.WriteLine("Under 25 is good.");
else if (bmi > 25)
Console.WriteLine("Your BMI above average, you should consider a diet
plan");
else
Console.WriteLine("uh, oh...what happend!");

}
}
}
Nov 15 '05 #1
3 3871
oops, my bad, forgot to put the braces on my if's
Nov 15 '05 #2
Looks good to me, what do you think is wrong?

Randy
http://www.kbcafe.com

"Robert Blackwell" <robbieatwowcentraldotcom> wrote in message news:<eT**************@TK2MSFTNGP10.phx.gbl>...
What am I doing wrong here?

using System;

namespace SchoolStuff
{

class BodyFat
{
public static void Main()
{
const double kiloToPound = 2.2046, inchToMeter = 39.370;
double weight, height;
double kilograms, meters;
Console.WriteLine("Please enter your name");
string name = Console.ReadLine();
Console.WriteLine("Thank you "+ name);
Console.WriteLine("Enter weight in pounds:");
string data = Console.ReadLine();
weight = double.Parse(data);
kilograms = weight / kiloToPound;
Console.WriteLine("\nThis is approximately {0:F2} kg.", kilograms);

Console.WriteLine("\nEnter height in inches:");
data = Console.ReadLine();
height = double.Parse(data);
meters = height / inchToMeter;
double bmi;
bmi = kilograms / (meters * meters);
Console.WriteLine("\nYour BMI is approximately {0:F2}.", bmi);

if (bmi == 25)
Console.WriteLine("25 is average.");
else if (bmi < 25)
Console.WriteLine("Under 25 is good.");
else if (bmi > 25)
Console.WriteLine("Your BMI above average, you should consider a diet
plan");
else
Console.WriteLine("uh, oh...what happend!");

}
}
}

Nov 15 '05 #3
I forgot to enclose my if/else if's with braces
Nov 15 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Jim | last post by:
im using asp.net, C# to enter data into a table in sql server...however im getting this error: Input string was not in a correct format. Description: An unhandled exception occurred during the...
0
by: lianfe_ravago | last post by:
Input string was not in a correct format. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the...
5
by: blackg | last post by:
Input string not in correct format -------------------------------------------------------------------------------- I am trying to view a picture from a table. I am getting this error Input string...
1
by: amitbadgi | last post by:
Welcome back amitbadgi | Logout | Faq Knowledge Discovery Keys COMPUTER PROGRAMMING, DATA MINING, STATISTICS, ARTIFICIAL INTELLIGENCE * Settings * Photos * Lists * MVPs * Forums * Blogs
1
by: amitbadgi | last post by:
I am gettign this error, while migration an app to asp.net Exception Details: System.FormatException: Input string was not in a correct format. Source Error: Line 19: Dim enddate =...
0
by: hudhuhandhu | last post by:
have got an error which says Input string was not in a correct format. as follows.. Description: An unhandled exception occurred during the execution of the current web request. Please review the...
0
by: Anonieko | last post by:
Are there any javascript codes there? Answer: Yes On the PageLoad event call InitialClientControsl as follows /// <summary> /// This will add client-side event handlers for most of the...
0
by: sehguh | last post by:
Hiya Folks, I am Currently using windows xp. Also using Visual Web Developer 2005 and Microsoft Sql server 2005. The main page consists of an aspx page and a master page. The page also...
1
by: sehguh | last post by:
Hello folks I have recently been studying a book called "sams teach yourself asp.net 2.0 in24 hours by scott mitchell. I have reached page 614 but when i tried to run an asp page called...
1
by: differentsri | last post by:
THIS IS AN ASP.NET 1.1 APPLICATION IAM TRYING TO UPDATE THE FIELD BUT I AM NOT ABLE TO UPDATE IT? CAN U TELL THE REASON ? IT IS GIVING THE FOLLOWING ERROR BELOW I HAVE ALSO GIVEN THE CODE OF...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.