Coder Profile - Show off your skills, get a coder profile.
 
 
 
  
Posted: 110 Days Ago 

befigard
United States
Contrib Level: 1
Total Posts: 1
I am very new to java. I'm really having a tough go of trying to make this GUI function properly. The more I try to fix it, the worse it becomes...so much so that it will not function at all now. Can someone please help me. (I have asked my instructor on many occassions, however he refers me to the confusing text we are to use...and I am a visual learner.)
CODE: Copy / Restore  ::  Remove Scroll Bars
  1. package pkgfinal;
  2.  
  3. import java.util.Scanner;
  4. import javax.swing.JOptionPane;
  5.  
  6. /**
  7.  *
  8.  * @author Bert
  9.  */
  10. public class Final {
  11.     private static boolean WeightCalculator;
  12.  
  13.     /**
  14.      * @param args the command line arguments
  15.      */
  16.     public static void main(String[] args) {
  17.  
  18.             WeightCalculator wc = new WeightCalculator(this);
  19.  
  20.             boolean validData = false;
  21.             double weight = 0;
  22.             String strWeight = "";
  23.             String strDescription = "";
  24.             Scanner s = new Scanner(System.in);
  25.  
  26.  
  27.                 strDescription = JOptionPane.showInputDialog("Enter description of the object ");//input from user
  28.                 strWeight = JOptionPane.showInputDialog("Enter weight of the object ");//input from user
  29.  
  30.  
  31.                 weight = Double.parseDouble(strWeight);
  32.                  wc.setWeight(weight);
  33.                  wc.setDescription(strDescription);
  34.  
  35.             do {
  36.  
  37.                     JOptionPane.showMessageDialog(null, "Please enter valid value for weight. It should be between 0 and 99999","Inane Error", JOptionPane.ERROR_MESSAGE);//output to user, error message
  38.                     validData = false;
  39.  
  40.                 while (weight < 0 || weight < 99999) {//sets the parimeters for the error message
  41.                     validData = true;
  42.  
  43.                 }
  44.               if (validData = true){
  45.                     continue;
  46.  
  47.  
  48.  
  49.             JOptionPane.showMessageDialog(null, "The weight of on Mercury is: " + wc.mercuryWeight(), "Result ", JOptionPane.PLAIN_MESSAGE);
  50.             JOptionPane.showMessageDialog(null, "The weight of on Earth is: " + wc.earthWeight(), "Result ", JOptionPane.PLAIN_MESSAGE);
  51.             JOptionPane.showMessageDialog(null, "The weight of on the Moon is: " + wc.moonWeight(), "Result ", JOptionPane.PLAIN_MESSAGE);
  52.             JOptionPane.showMessageDialog(null, "The weight of on Jupiter is: " + wc.jupiterWeight(), "Result ", JOptionPane.PLAIN_MESSAGE);
  53.  
  54.  
  55.               }
  56.  
  57.  
  58.  
  59. public WeightCalculator {
  60.  
  61.  
  62.     public double earthWeight() {
  63.         return weight;
  64.     }
  65.  
  66.     public double mercuryWeight() {
  67.         return weight * 0.378;
  68.     }
  69.  
  70.     public double moonWeight() {
  71.         return weight * 0.166;
  72.     }
  73.  
  74.     public double jupiterWeight() {
  75.         return weight * 2.364;
  76.     }
  77.  
  78.     public String getDescription() {
  79.         return description;
  80.     }
  81.  
  82.     public void setWeight(double weight) {
  83.         this.weight = weight;
  84.     }
  85.  
  86.     public void setDescription(String description) {
  87.         this.description = description;
  88.     }
  89.  
  90. }
Page 1 of 1
 
 
Latest News About Coder Profile
Coder Profile Poll
Which sounds better on your coder profiles, and makes more sense to you (think twitter, facebook, etc)?

Followers / Following
Fans / Following
Fans / Fan Of


please login to cast your vote
and see the results of this poll
Latest Coder Profile Changes
Coder Profile was last updated
3.49 Years Ago
Official Blog :: Make A Donation :: Credits :: Contact Me
Terms & Conditions :: Privacy Policy :: Documents :: Wallpapers
Version 1.46.00
Copyright © 2007 - 2012, Scott Thompson, All Rights Reserved