Java Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingJava Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old February 20th, 2005, 06:46 PM
storms831 storms831 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2005
Posts: 1 storms831 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 9 m 28 sec
Reputation Power: 0
Question java help

I am working on a programming project. I have been stuck for several days.I am including what I have so far and what I am trying to do any help with this would be greatly appreciated.
Write a program that allows the user to convert either from degrees Celsius to Fahrenheit or from degrees Fahrenheit to Celsius. Use the following formulas:
degreesC = 5(degreesf - 32)/9
degreesF = (9(degreesC)/5) + 32
Promt user to enter a temperature and either a 'C' or 'c' for Celsius or an 'F' or 'f' for Fahrenheit allow either uppercase or lowercase and if anything other than that print an error message. Convert the temperature to Fahrenheit if Celsius is entered or Celsius to Fahrenheit is entered.
Below is what I have. I am not sure where I am messing up:
// Convert either Fahrenheit or Celsuis formulas

publicclass ConvertDegrees2
{
publicstaticvoid main (String[] args)
{

char answergiven =' ';
int DegreesF = 00;
int DegreesC = 00;
int orgDegreesF = 00;
int orgDegreesC = 00;


System.out.println(
"Enter a temperature: ");
System.out.println(
"Enter 'c' or 'f':");
answergiven = SavitchIn.readLineNonwhiteChar();

if((answergiven=='F')||(answergiven=='f'));
answergiven = SavitchIn.readLineNonwhiteChar();
DegreesF = 9*(DegreesC)/5 + 32;
DegreesF = SavitchIn.readLineInt();

orgDegreesC = DegreesC;
if ((answergiven=='C')||(answergiven=='c'));
answergiven = SavitchIn.readLineNonwhiteChar();
DegreesC = 5*(DegreesF - 32)/9;
DegreesC = SavitchIn.readLineInt();

//
System.out.println(orgDegreesF + "Degrees in Fahrenheit = " + DegreesC + " Degrees Celsius ");
System.out.println(orgDegreesC +
"Degrees in Celcius = " + DegreesF + "Degrees Fahrenheit ");
System.out.println(
"Press 'Q' or 'q' to quit or any key to repeat program.");
}
}





Reply With Quote
  #2  
Old February 21st, 2005, 09:14 AM
MadCowDzz's Avatar
MadCowDzz MadCowDzz is offline
I'm Internet Famous
Dev Articles Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2003
Location: Toronto, Canada
Posts: 2,890 MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Week 16 h 14 m 9 sec
Reputation Power: 8
Where's the problem?

Reply With Quote
  #3  
Old February 21st, 2005, 09:16 AM
MadCowDzz's Avatar
MadCowDzz MadCowDzz is offline
I'm Internet Famous
Dev Articles Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2003
Location: Toronto, Canada
Posts: 2,890 MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Week 16 h 14 m 9 sec
Reputation Power: 8
You might want spaces between publicclass as well as publicstaticvoid...
I assume that happened when you colorized your post.

I do see further problems, but as this is a school assignment I think its better for you to spot them on your own...
I'm willing to guide you, but I won't give you the solution.

What happens when you run your code?

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingJava Development > java help


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
Stay green...Green IT