Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Converting this into GUI?

  1. #1
    Junior Member
    Join Date
    Nov 2012
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Converting this into GUI?

    Okay so im not completely done with this program, but i want to get it working in GUI and then applet before i move on in it, its a grading program that then spits out grades needed for an A for now, whats the easiest way to convert this into GUI, ive really only used joptionpane and not really all that much looking for any and all help maybe if someone could convert one section of it for me would be amazing as well where i could look at it for how to do the rest!
    And for example the last part from "For an A in this class you will need the following grades: through all of the assignments id like all of that on one panel! Ive got this program to work but gah am i horrible at GUI

    Thanks!

    import java.util.Scanner;
     
     
    public class Prog5 {
     
    	public static void main(String args[])
    	{
    		int numberOfGrades;
    		int grade = 0; 
    		int gradesDone = 0;
    		int completed;
    		float totalPoints = 0;
    		int points;
    		float pointsEarned = 0;
    		float remainingPoints;
    		int aLeft;
    		float assignment = 0;
    		int aCounter = 0;
     
     
     
    		Scanner input = new Scanner( System.in );
     
    		System.out.println("How many total grades will there be? ");
    		numberOfGrades = input.nextInt();
     
    		int [] grades = new int [numberOfGrades+1];
     
    		do            
    		{
     
    		grade++;
    		System.out.println("Points possible for assignment " + grade + ":");
    		grades[grade] = input.nextInt();
     
     
     
    		}while (grade < numberOfGrades);
     
     
    		for ( int counter=1; counter < grades.length; counter++ )
    			totalPoints += grades[counter]; 
     
     
     
    		System.out.println("an ID "+ java.util.Arrays.toString(grades));
    		System.out.println(totalPoints);
     
    		System.out.println("How many assignments completed?");
    		completed = input.nextInt();
     
     
    		int [] completedArray = new int [completed+1];
     
     
     
    		do            
    		{
    		 gradesDone++;
     
    		System.out.println("Points recieved on assignment " + gradesDone + ":");
    		completedArray[gradesDone] = input.nextInt();
     
     
     
    		}while (gradesDone < completed);
     
    		for ( int counter=1; counter < completedArray.length; counter++ )
    			pointsEarned += completedArray[counter]; 
     
    		remainingPoints =  (totalPoints - pointsEarned);
    		aLeft = numberOfGrades - completed;
     
     
     
    		do            
    		{
    		 assignment++;
     
     
     
    		}while (((pointsEarned+assignment)/(totalPoints)) <= .895);
     
     
    		System.out.println("For an A in this class you will need the following grades:");
     
    		do
    		{
     
    			aCounter++;
     
    			if ((assignment-grades[gradesDone+aCounter])>0)
    			{
    			System.out.println("Assignment " + (gradesDone+aCounter) + ": " + 
    			(int) (grades[gradesDone+aCounter]));
     
    			assignment = assignment-grades[gradesDone+aCounter];
     
    						}
     
    			else
    			{
    				System.out.println("Assignment " + (gradesDone+aCounter) + ": " + (int) assignment);
     
    				assignment = assignment-grades[gradesDone+aCounter];
    			}
     
    		}while (assignment > 0);
     
     
     
     
     
     
    	}
    }


  2. #2
    Super Moderator curmudgeon's Avatar
    Join Date
    Aug 2012
    Posts
    1,130
    My Mood
    Cynical
    Thanks
    64
    Thanked 140 Times in 135 Posts

    Default Re: Converting this into GUI?

    First off, get all of that code out of the main method and instead create a proper class with instance fields and methods. Until you do that, you'll not be able to make a GUI out of any of this.

Similar Threads

  1. Converting?
    By SilentNite17 in forum What's Wrong With My Code?
    Replies: 3
    Last Post: October 31st, 2012, 05:18 AM
  2. Converting Name.
    By LoganC in forum What's Wrong With My Code?
    Replies: 3
    Last Post: October 10th, 2012, 08:09 AM
  3. Converting a Java App to an Applet(with no GUI)
    By davidvee in forum What's Wrong With My Code?
    Replies: 4
    Last Post: July 2nd, 2012, 12:40 PM
  4. Converting Cases Help
    By Bradshjo in forum What's Wrong With My Code?
    Replies: 6
    Last Post: September 27th, 2010, 12:07 PM
  5. Replies: 3
    Last Post: February 1st, 2010, 12:24 AM