mattyg1192003

Thank you very much sir! it all was stemming from the area.getText().equals. I appreciate you taking the time to help me out.

mattyg1192003 Newbie Poster

Hello everyone,

I have a question regarding a Japplet that I am creating for a theatre. The program is supposed to take a yes or no response from the user, take which section the user will be sitting in, ask how many tickets they would like to purchase, and then calculate their total cost when the total button is clicked. The problem I am having is that when I click the total button nothing is happening. I think it may be because I have my while loops in the wrong place, but any help you can give me would be much appreciated!

[CODE]import javax.swing.;
import java.awt.
;
import java.awt.event.*;
import java.text.DecimalFormat;

/*
The Test class is an applet that calulates
ticket prices for a theatre.
/

public class Test extends JApplet
{
private JPanel mPanel; // To hold a text field
private JPanel aPanel; // To hold a text field
private JPanel bPanel; // To hold a text field
private JPanel tPanel; // To hold a text field
private JPanel buttonPanel; // To hold a button
private JTextField member; // members
private JTextField area; // seating area
private JTextField ticketnum; // tickets
private JTextField total; // total cost

/*
init method
/

public void init()
{
// Build the panels.
buildmPanel();
buildaPanel();
buildbPanel();
buildtPanel();

buildButtonPanel();

// Create a layout manager.
setLayout(new GridLayout(5, 1));

// Add the panels to the content pane.
add(mPanel);
add(aPanel);
add(bPanel);
add(tPanel);
add(buttonPanel);
}

/**
The buildtPanel method creates a panel with a text
field in which the ...

mattyg1192003

Thank you so much Ahmed! I can't believe I didn't spot that before, but like they say it is always the simplest problems that throw you for a loop! Thanks again everyone for all of the help and I greatly appreciate it! :)

mattyg1192003 Newbie Poster

Hey Guys,

I am a new student to Java and I am working on an assignment for school. I am not looking for anyone to do my work for me, just some guidance on what I can do to fix the problem. I have done research on this issue on google and visited various sites without getting the information I am looking for. I have contacted my professor as well, but he is usually very slow at responding to my questions. I am running out of time for this assignment and I would like to fix this bug before submitting the assignment.

Okay, now that the formalities are out of the way, here is the code that I have written thus far:

[CODE]import java.util.Scanner;
public class CalculateGrade {

public static void main(String[] args) {
//main method calls AssignvalueToArray method, and AssignValueToArray method calls
//DisplayvalueInArray method

//create a Scanner object for input
Scanner keyboard = new Scanner(System.in);
System.out.print("Enter the number of students: ");
int studentNum = keyboard.nextInt();
System.out.println();
System.out.print("Enter the number of Exams: ");
int studentExamNo = keyboard.nextInt();

AssignValueToArray(studentNum, studentExamNo);

}

//This method assigns students' scores to a two dimensional array
public static void AssignValueToArray(int studentNumber, int numberOfExam)
{
int[][] studentScore = new int[studentNumber][numberOfExam];
Scanner keyboardForArray = new Scanner(System.in);

int studCount = 1;
for (int index = 0; index < studentNumber; index++)
{
System.out.println ("Please type in student " + studCount + " 's grades: " );
for(int indexOfExam=0; indexOfExam < numberOfExam; indexOfExam++)
{
    studentScore[index][indexOfExam] = keyboardForArray.nextInt();

studCount++;
}

DisplayvalueInArray(studentScore);
} ...