« Previous entry | Next entry » Browse > Snippets

Skip to comments (3) java while
Posted by guest on Aug 10 2006 @ 09:05  :: 2838 unique visits

class lesson4d

{

static public void main(String [] args)
{
int choice=0;
String value="";
while (choice != 5)
{
value = JOptionPane.showInputDialog(
"Enter 1 for Grade Problem\n" +
"Enter 2 for Circle Problem\n" +
"Enter 3 for Rectangle Problem\n" +
"Enter 4 for Even-Odd Problem\n" +
"Enter 5 to Exit");
choice = Integer.parseInt(value);

switch (choice)
{
case 1:

int input1;
String inputGrade1;
String inputGrade2;
float midGrade = -1;
float finGrade = -1;
float result = 0;

char letGrade = 'z';

String substringInputGrade1;
char substringChoice = 0;

inputGrade1 = JOptionPane.showInputDialog("Enter midterm grade:");
midGrade = Float.parseFloat(inputGrade1); // convert string to type Float

if (midGrade < 0 || midGrade > 100)
{
JOptionPane.showMessageDialog(null, "Out of range, please enter grade again:");
}

while (finGrade < 0 || finGrade > 100 ) // Input of Final Grade
{
inputGrade2 = JOptionPane.showInputDialog("Enter grade received for final:");
finGrade = Float.parseFloat(inputGrade2);

if (finGrade < 0 || finGrade > 100)
{
JOptionPane.showMessageDialog(null, "Out of range, please enter grade again:");
}
}

DecimalFormat decResult = new DecimalFormat( "0.00");
  result = (2 * midGrade + finGrade) / 3;
letGrade = assignGrade (result);

JOptionPane.showMessageDialog(null,
"Grade received in class is: " + decResult.format (result) +
"\nLetter grade = " + letGrade ,
"Grade received", JOptionPane.INFORMATION_MESSAGE);
break;
}
} // close first while loop
System.exit(0);

}
  static char assignGrade ( float result )
{
char letGradeF = 'z';
if ( result >= 90 )
letGradeF = 'A' ;
else if ( result >= 80 )
letGradeF = 'B';
else if ( result >= 70 )
letGradeF = 'C';
else if ( result < 70 )
letGradeF = 'F';
return letGradeF;
}

}

3 comments posted so far
Add your own »

1. On Mar 15 2009 @ 16:15 guest wrote:

Our wholesale replica handbags  is one of the best Replica Purses  wholesaler.we are selling  Louis vuitton replica ,Chanel Replica ,Gucci Replica ,The handbags are Hermes Birkin ,Hermes Kelly ,Chanel 2.55 bag ,Louis vuitton replica Speedy 30 ,Louis vuitton Damier Canvas ,and we selling high and top Chanel wallet ,Louis Vuitton wallet ,Hermes belt . Choosing Replica handbags  to perfect your lifestyle: Business Opportunities.

Jadeshow’s replica Tiffany Jewelry  and Replica Bvlgari Jewelery  looks just like the real thing. Why pay more for a single piece of Tiffany Replica  jewelry,Bvlgari Replica Jewelry  when you can treat yourself to a number of replica pieces for the same price or less? Be simply spectacular with contemporary Tiffany-inspired jewelry!Jadwshow delights in the opportunity to offer our customers fine Tiffany Bracelets , Tiffany Necklaces , Tiffany Earrings , Tiffany Rings , Tiffany Bangles ,Gucci jewelry replica , Chanel wallet  and Louis Vuitton wallet
all at remarkably low prices.

We are top designer wholesale Replica handbags ,Louis vuitton replica  ,replica jewelry ,Bvlgari Replica ,Gucci Replica jewelry ,Swarovski Crystal , We offer a wide variety of high quality Tiffany inspired jewelry at very low prices. Gucci Necklaces ,Gucci Bracelets , Gucci rings , Gucci Earrings , Links Jewelry ,Chanel Rings  and Tiffany replica , Cartier Jewelry   more. Free shipping with any purchase over 5 items.Replica Louis Vuitton chanel replica handbag



We are the best and top Replica handbag  ,replica bags ,Replica watches  wholesaler in china,Our products is Replica louis vuitton handbags ,Chanel replica handbags ,Gucci replica handbags ,Miu Miu handbag  and we are selling Replica wallet ,best Louis Vuitton wallet ,Chanel wallet  replica,and sell Rolex replica watches ,Omega replica watches .Hermes replica bag

3. On Jan 05 2010 @ 14:44 uggbaileybutton wrote:

bailey button uggs

-ugg boots cheap

ugg boots uk

ugg classic

Add a new comment

Name:
Password: (leave empty for anonymous comment)
 
View formatting tags Comment: