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 October 6th, 2006, 09:55 AM
stallion stallion is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2006
Posts: 1 stallion User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 m 29 sec
Reputation Power: 0
Help Please

Hello all!

I am taking an intro to programming course at a local university and I have been assigned some programs to write in the first week. I have no knowledge of java writing programs and would appreciate some help on completeing these programs or just getting started the programs I need to write are:



a Java program to convert centimeters (input) to feet and inches (output). Use the following: 1 inch = 2.54 centimeters



Question 4:



a Java program that prompts you for your first name and your last name and then displays your name in reverse order, ie last name followed by the first name.



Question 5:



a Java program that inputs temperature in Celsius and prints out the temperature in Fahrenheit. The formula to convert Celsius to Fahrenheit is:

fahrenheit = 1.8 x celsius + 32



Question 6:



a Java program that accepts a person’s weight and displays the number of calories the person needs in one day. A person needs 19 calories per pound of body weight, so the formula expressed in Java would be:

calories = bodyWeight * 19

All help is appreciated!
Thanks!

Reply With Quote
  #2  
Old October 6th, 2006, 11:01 AM
Icon's Avatar
Icon Icon is online now
Command Line Warrior
Click here for more information.
 
Join Date: Sep 2005
Posts: 703 Icon User rank is Private First Class (20 - 50 Reputation Level)Icon User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 1 Week 2 Days 23 h 49 m 39 sec
Reputation Power: 4
Any help is gladly given on the problems you encounter when doing the exercises yourself. From what I see you'll need to read up on some primitive Java classes/types: String, int ,and double. Good luck!

Reply With Quote
  #3  
Old October 6th, 2006, 11:43 AM
colton22's Avatar
colton22 colton22 is offline
\ ^_^ / - Moderator
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2006
Location: near chicago, Illinois
Posts: 473 colton22 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 Days 1 h 19 m 14 sec
Reputation Power: 3
Send a message via AIM to colton22 Send a message via MSN to colton22 Send a message via Yahoo to colton22
Question 1:a Java program to convert centimeters (input) to feet and inches (output). Use the following: 1 inch = 2.54 centimeter
Code:
public double toFeet(double cm) {
double feet=(cm/2.54)/12;
return feet;
}
public double toInches(double cm) {
double inc=cm/2.54;
return inc;
}

Question 2:a Java program that prompts you for your first name and your last name and then displays your name in reverse order, ie last name followed by the first name.
Code:
public String getname() {
	String nome="",nombre=JOptionPane.showInputDialog("Enter Your Name [ie:Joe Smith]").trim();
	String firstname=nombre.substring((int) 0,nombre.indexOf(" "));
	String lastname=nombre.substring((int) nombre.indexOf(" ")+1,(int) nombre.length());
	nome=lastname+", "+firstname;
	return nome;
	}


ill be back on later to answer more...

colton22

Reply With Quote
  #4  
Old October 6th, 2006, 12:26 PM
colton22's Avatar
colton22 colton22 is offline
\ ^_^ / - Moderator
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2006
Location: near chicago, Illinois
Posts: 473 colton22 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 Days 1 h 19 m 14 sec
Reputation Power: 3
Send a message via AIM to colton22 Send a message via MSN to colton22 Send a message via Yahoo to colton22
Question 3:a Java program that inputs temperature in Celsius and prints out the temperature in Fahrenheit. The formula to convert Celsius to Fahrenheit is:

fahrenheit = 1.8 x celsius + 32
Code:
public void getDegree() {
boolean _errorinput=false;
double d_c=0;
//GET A GOOD NUMERICAL INPUT...
do {_errorinput=false;
String c=JOptionPane.showInputDialog("Enter The Degree In Celsius");
try {d_c=Double.parseDouble(c);}catch(NumberFormatExce  ption e) {_errorinput=true;}
}while(_errorinput);

d_c=(1.8*d_c)+32;
JOptionPane.showMessageDialog(null,Double.toString  (d_c));
}

Question 4: a Java program that accepts a person’s weight and displays the number of calories the person needs in one day. A person needs 19 calories per pound of body weight, so the formula expressed in Java would be:

calories = bodyWeight * 19
Code:
public void getWeight() {
boolean _errorinput=false;
double weig=0;
//GET A GOOD NUMERICAL INPUT...
do {_errorinput=false;
String c=JOptionPane.showInputDialog("Enter The Degree In Celsius");
try {weig=Double.parseDouble(c);}catch(NumberFormatExc  eption e) {_errorinput=true;}
}while(_errorinput);

weig=weig*19;
JOptionPane.showMessageDialog(null,Double.toString  (weig));
}


hope these helped!!!

colton22

p.s. You could Email Me at: colton22@comcast.net for more help.

Last edited by colton22 : October 6th, 2006 at 12:28 PM. Reason: added my email

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingJava Development > Help Please


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 5 hosted by Hostway
Stay green...Green IT