Home Tutorialhelp Comment Please help me display the output in if else loop

 
 

Comment

Radhika
Please help me display the output in if else loop ,
September 22, 2009 at 8:37 PM

I would like to know how do I display the output the one's that come under this method using JLabel which comes under if else loop
"Correct" & if it's wrong " ("Sorry! The correct answer is c \n")" & "("Congratulations,you passed with a score of "+score+ "%\n");"


public void itemStateChanged(ItemEvent e)
{
int numberCorrect=0;
int score;

Checkbox user1Selection = ques1Grp.getSelectedCheckbox();
System.out.println(user1Selection);
if(user1Selection == c1)// checks whether the answer matches
{
System.out.println ("Correct");//displays correct if the answer matches
numberCorrect++; // adds 1 to the number of correct answers
}else
System.out.println("Sorry! The correct answer is c \n"); // if the answer is incorrect displays the correct answer


Checkbox user2Selection = ques2Grp.getSelectedCheckbox();
System.out.println(user2Selection);
if(user2Selection == b2)// checks whether the answer matches
{
System.out.println("Correct");//displays correct if the answer matches
numberCorrect++; // adds 1 to the number of correct answers
}else
System.out.println("Sorry! The correct answer is b \n"); // if the answer is incorrect displays the correct answer


Checkbox user3Selection = ques3Grp.getSelectedCheckbox();
System.out.println(user3Selection);
if(user3Selection == a3)// checks whether the answer matches
{
System.out.println("Correct");//displays correct if the answer matches
numberCorrect++; // adds 1 to the number of correct answers
}else
System.out.println("Sorry! The correct answer is a \n"); // if the answer is incorrect displays the correct answer


Checkbox user4Selection = ques4Grp.getSelectedCheckbox();
System.out.println(user4Selection);
if(user4Selection == c4)// checks whether the answer matches
{
System.out.println("Correct");//displays correct if the answer matches
numberCorrect++; // adds 1 to the number of correct answers
}else
System.out.println("Sorry! The correct answer is c \n"); // if the answer is incorrect displays the correct answer


Checkbox user5Selection = ques5Grp.getSelectedCheckbox();
System.out.println(user5Selection);
if(user5Selection == d5)// checks whether the answer matches
{
System.out.println("Correct");//displays correct if the answer matches
numberCorrect++; // adds 1 to the number of correct answers
}else
System.out.println("Sorry! The correct answer is d \n"); // if the answer is incorrect displays the correct answer
System.out.println("\n You had "+numberCorrect+" question correct.\n");// displays number of questions correct

score = (numberCorrect*20);//score calculation
if (score>=60)
{
// Displays the end result if the user scores >= 60 it congratulates them or if it's <60 displays better luck next time.
System.out.println("Congratulations,you passed with a score of "+score+ "%\n");
}else{
System.out.println("Sorry, your grade was "+score+"% Better luck next time!");

repaint();}

View All Comments | View Tutorial
Advertisement
Related Tutorial and Articles
Java Beginners

please help me here
please help me here  please show me how can this show the right output that i need please continue doing this program using only if else and do while please please" here is the problem Automatic Teller Machine [B] Balance [D 

Java Beginners

please help me here
please help me here  please show me how can this show the right output that i need please continue doing this program using only if else and do while please please" here is the problem Automatic Teller Machine [B] Balance [D 

Java Beginners

Please help me??
Please help me??  Question_1: Using one-dimension array of primitive... to have 8 elements as follows:2, 3, 5, 7, 11, 13, 17, and 19 4. Display... and Iterator. Step1: Create a new java file FileName: ListDemo.java import 

Java Beginners

please help me - Java Beginners
please help me   I have some error in this programe //write acomputer programe using java to generate following series : //output: //1,2,3,0,-2,7,-4..... class Series1HW { public static void main(String args 

Java Beginners

PLEASE HELP WITH MY JAVA
please help!!!!!!!! it is a for-loop question: Display the first 5 multiples...PLEASE HELP WITH MY JAVA  Hey my name is Gavin and im a student... and average If u can please help...    

Swing AWT

GUI
GUI  How to GUI in Net-beans ... ??   Please visit the following link: http://www.roseindia.net/java/java-tips/background/30java_tools/netbeans.shtml 

Java Beginners

I need help on my Java code.... please please help me out!?
I need help on my Java code.... please please help me out!?  Well my... in the file. Also it should be displayed on the screen. However my code doesn't display the anagram on screen or the output file! Please show me whats wrong. Thanks i 

Java Beginners

Java Help Please
Java Help Please  I can't seem to figure out how to make this program, can some one help me please? It is due soon!! 4) Write a program... a date (3 ints) and display the next date. Example: Input: 02 14 2013 Output 

Java Beginners

urgent...pleAse help me.....please!
urgent...pleAse help me.....please!  please help me urgent! how can i do dictionary with the use of array code in java, where i will type the word then the corresponding meaning for that word will appear...thanks 

JSP Servlet Questions

please help me.
please help me.  How to read a properties file in java with a suitable example. Please send me. Thanks Trinath   Please visit the following link: Java read properties file 

Java Beginners

please help me in a java program !! - Java Beginners
please help me in a java program !!  the porgram should use kosaraju's algorithm to detect the strong connected components in a graph (http://en.wikipedia.org/wiki/Kosaraju_algorithm) there are 4 classes in my program : Vertex 

Java Beginners

Java GUI code- creating a circle
, can someone please help me? import javax.swing.*; import java.awt....Java GUI code- creating a circle  My assignment is to write a program...; //GUI components JLabel lClx, lCly, lCircumrx, lCircumry, lRadius 

Java Beginners

GUI Interface - Java Beginners
GUI Interface  Respected sir, please send me the codimg of basic... and multiplication. But use classes javax swing java awt java awt.event no other classes wil be used.I need it very urgent please help me for this  Hi 

JSP Servlet Questions

Display JSP selected listbox and checkbox in xml-please help me
Display JSP selected listbox and checkbox in xml-please help me  Hi... as selected multiple checked checkboxes. Please help in this how to do this.....I am new to java & jsp I need your help. Regards 

Java Beginners

help me please
help me please  how can i do dictionary with the use of array code in java, where i will type the word then the corresponding meaning for that word will appear...thanks 

Java Beginners

please help me here.. - Java Beginners
please help me here..  ..uhhmm.. im a little bit new to java and i go...(" The First string is a part of the Second String"); } else... if the first string is part of the second string... ..help..  Hi friend 

Java Beginners

please help me to give code - Java Beginners
please help me to give code  Write a program that reads a file named... is not exist"); else{ FileInputStream finp=new FileInputStream(file); byte b...(); } } } ------------------------------- read for more information, http://www.roseindia.net/java/beginners/read 

Java Beginners

help please?
help please?  Define a class named Circle with the following... with the given radius value as the argument. ? A public method to display the Circle... the second object must be created with the radius value of 8. Display 

SQL Question

Please help me out
Please help me out    Description* You are hired to develop a laptop inventory information system for Sheridan College in order to keep track... or Eclipse), you should develop a Java application to provide these services 

Java Beginners

Help me please!!! - Java Beginners
Help me please!!!  im badly needing the complete code for this project in java!!! can you please help me???!!! it is about 1-dimensional array... the answers 8Hours from now!!! Kindly help me!! please!!please!!! NOTE 

Java Beginners

Help me please with my final homework
Help me please with my final homework  Write a Java program of your choice that demonstrates the following concepts: ? Input and Output. ? Selection/Conditional (e.g. if statement). ? Arithmetic. ? Loops. ? Arrays 

WebSevices Questions

Please help me to learn - WebSevices
Please help me to learn  Please help me to learn Java Fast 

JavaScript Questions

Java sample using - for loop, if then else etc etc
Java sample using - for loop, if then else etc etc  sample program..., and items code range from 100-300 if Item code is 100-150, display " aim high" if item code is 150-200, display "good sales" if item code is 250-300, display 

Java Beginners

Gui plz help
Gui plz help   Create a Java application that would allow a person... questions are asked and answered, display a message to the user that would state either... far. so basically what i did is i used the java palletes to make a application 

Java Beginners

please help me to overcome this problem
please help me to overcome this problem  how to make it easy to write java code. can u please give me suggestions 

Java Beginners

help please - Java Beginners
help please  i wrote this program but the function newLine dosnt work with me and i dont know where is exactly the error this is the code i... example!"); int num = 100; Writer output = null; File file = new 

Ajax Questions

ajax code please help to solve this........
null; } please help me when i am running this it show an error...ajax code please help to solve this.  in this i am trying to get data from datbase and put it in combo box and then display it down using table 

Java Beginners

java please please help
java please please help  Dear Friends plz help me to complete...[] to HashMap so that i can seperate key and value using Map.Entry.Please help me!  ... = map.entrySet(); Iterator it = set.iterator(); while(it.hasNext()) { Map.Entry me 

Java Interview Questions

help
based on the percentage of cheating. please help me...help  please answer these two assignments every one related to each other for me before Tuseday I answer the first part please continue to me 

Java Beginners

While loop break causing unwanted output
While loop break causing unwanted output  Below I will paste my code... it will output that I was correct but after that it will output something that I'm not understanding which is"hack2@1f24bbbf". Any help will be greatly appreciated 

Java Beginners

help me - Java Beginners
help me  helo guys can you share me a code about Currency Conversion.Money will convert according to the type of currency.would you help me please... into 2 decimal places sample 1.25) Mexican_________ guys help me..thank 

Java Interview Questions

Please find me a solution that
Please find me a solution that   Write a java program... and Math.pow() function for your calculation. e. One Void Display Method... to pass the result as a parameter to Display Method to print it out. There is one 

Java Beginners

Please help me to modify my java code from php code
the exact result as the above PHP code is giving. So please help me to convert...Modify Java code from PHP Code  i want to covert this php code int java/JSP. if (isset($_POST['orders'])) { $orders = explode('&', $_POST 

Java Beginners

plz explain me the output of program - Java Beginners
plz explain me the output of program  Hi friends, can u please explain me the output of below program with proper explanation of each and every line...;Hi Friend, Output of this program is: a=2 b=0 c=0 mul=27 volume=18 

Java Beginners

please help
please help  please send me the code of dynamic stack in java without using the built in functions 

Java Beginners

please help me to give code - Java Beginners
please help me to give code  Write a function with a signature cheerlead(word) that prints a typical cheer as follows. The word robot: Gimme an R Gimme an O Gimme a B Gimme an O Gimme a T What did you give me? ROBOT 

Java Beginners

please help me to give code - Java Beginners
please help me to give code  Write a function, sliding(word, num)that behaves as follows. It should print out each slice of the original word having length num, aligned vertically as shown below. A call to sliding(examples, 4 

Java Beginners

please help me to give code - Java Beginners
please help me to give code  Write a program that prints an n-level stair case made of text. The user should choose the text character..., http://www.roseindia.net/java 

Java Beginners

Please help me to modify my java code from php code
Please help me to modify my java code from php code  i want to covert... help me to convert it into Java. if (request.getParameter("orders") != null... same, as they alter it before. Please help me on this topic "how to order rows 

JavaScript Questions

please help me...
please help me...  write an application that print number in the following order using a FOR-Loop 1 2 3 4 5 2 4 6 8 10 3 6 9 1215 4 8 121620 5 10152025 

Java Beginners

please help me for this program - Java Beginners
please help me for this program   Write a program that asks the user for a starting value and an ending value and then writes all the integers (inclusive) between those two values. Enter Start: 10 Enter End: 14 10 

Java Beginners

please help me to give code - Java Beginners
please help me to give code  Write a program that uses loops to generate an n x n times table. The program should get n from the user. As a model here is a 4 x4 version: | 1 2 3 4 

Java Interview Questions

help please?
help please?  Define a class named Circle with the following... with the given radius value as the argument. ‚?Ę A public method to display the Circle..., while the second object must be created with the radius value of 8. Display 

JSP Servlet Questions

please help me.
please help me.  I have three table in mysql,and i hava create a excel sheet and add this sheet.but my question is in every sheet i can display one one table result.how can i do 

Java Beginners

Please help me urgent...........
Please help me urgent...........  For what kind of a problem would... and not a Tree Set   Hello Friend, If you want to display the list... the data as a list. If you want to display values with respect to the key 

Java Beginners

help me
help me  please send me the java code to count the number of similar words in given string and replace that word with new one 

Java Beginners

please help me
please help me  how to use two browse buttons, one browse button for displaying the first image and second for the second image along with its file path and also to display text file along with its path using layouts or panels 

Java Beginners

please help me
please help me  how to use two browse buttons, one browse button for displaying the first image and second for the second image along with its file path and also to display text file along with its path using layouts or panels 

Java Interview Questions

please help me - Java Interview Questions
 

Java Beginners

Need Help Like No one Else Please
Need Help Like No one Else Please   write a program that computes miles per gallon for an automobile. The program should ask for the beginning... of gallons of gas. it should display the mileage for that fill-up as well 

Java Beginners

Please help with this Q ASAP
Please help with this Q ASAP  The University wants to make a basic graphical display to show how many people received different grades for a piece of work on a module. You are required to write a program in Java that achieves 

Java Beginners

please help me?
please help me?  Define a class named Circle with the following... radius value as the argument. A public method to display the Circle object... object must be created with the radius value of 8. Display the properties of both 

Java Beginners

Please help me
Please help me  Hi Sir, please send me the code for the following...} set2={15,25,35} output: union={10,15,20,25,30,35,40} 2) input: "Hi what are you doing" output: "doing you are what Hi"   1) import 

JavaScript Questions

help me in disabling checked checkboxes
help me in disabling checked checkboxes  <%@ page language="java... as enabled. I have stuck this problem from last 2 days....so please, help me out...); } else { enableInputs(this, inputs); } return true 

Java Beginners

pls. help me - Java Beginners
pls. help me  please help me i do need now if its okay...[] list = new int[50]; int[] Alist = new int[60]; int num; Write Java... parameters,the thirtieth and tenth components of list, respectively. d. Call 

Java Beginners

New to Java Please help
New to Java Please help  Hi I need help, can some one help me with this. I am currently doing a project. drop me an email to my email address. Thanks!   If you are new in java, then you need to learn core java 

JDBC Questions

Please help me... its very urgent
Please help me... its very urgent  Please send me a java code to check whether INNODB is installed in mysql... If it is there, then we need to calculate the number of disks used by mysql 

IDE Questions

help me
help me  MY GLASSFISH SERVER NOT START PROPERLY help me... [ GNUJAXP ] in the jarfile [ C:\Program Files\Java\jdk1.7.0_02\jre\lib\ext\gnujaxp.jar ] is not specified. Please provide a valid specification version 

Java Beginners

output
of this program.I got some useful help this website,but the output of the program isn't producing what it should.let me explain the output below is what happen when... help me with the code, the program is given below.Thank you! import java.util. 

Java Beginners

Help me
Help me  plz i want code of program to add real numbers and magic numbers in java example this input :- 5+3i-2+3i output:- 3+6i 

JDBC Questions

urgent help needed in JDBC AND JAVA GUI - JDBC
want any one to help me convert from scanner to java GUI for this code...urgent help needed in JDBC AND JAVA GUI  my application allows...; public class sAccount { void display() { Scanner input = new 

JDBC Questions

plz help me to create gui using Java netbeans
plz help me to create gui using Java netbeans  Hi, I am unable to fetch a particular data from DB.I am using netbeans for creating GUI. If I want.... I am unable to fetch the particular data. Plz help me   Hi Friend 

JSP Servlet Questions

Logic error? HELP PLEASE! :(
Logic error? HELP PLEASE! :(  Hello Guys! i have a huge problem. What... the page forward to the result page then all is display as null. But if I key in my email the page stuck which shows a blank page. By right it should display the date 

Java Beginners

java gui database - Java Beginners
the data on command line but I do not know how to display the same using java gui. Could anybody help me. Thanks. Shah...java gui database  I have eight files. Each file has exactly same 

Java Beginners

Writing a GUI program - Java Beginners
to write the code for the GUI. Could anyone please help?  Hi Friend...Writing a GUI program  Hello everyone! I'm trying to write a program that has a text field for input, two buttons and the output text area. A user 

Java Beginners

java gui-with jscroll pane
feilds through my program.... some one please help me.... Thanks in advance...java gui-with jscroll pane  Dear friends.. I have a doubt in my gui application. I developed 1 application. In this application is 1 Jscrollpane 

Java Beginners

java gui-with jscroll pane
feilds through my program.... some one please help me.... Thanks in advance...java gui-with jscroll pane  Dear friends.. I have a doubt in my gui application. I developed 1 application. In this application is 1 Jscrollpane 

JDBC Questions

Help me
out from java output so how to do all dis...Help me  hello!!!!. i have a Excel file which includes 4 columns and somewhat 8500 rows.these rows i have printed in SQL thru Excel file and i have 

Java Beginners

Java Variables Help Please!
Java Variables Help Please!  Hi, I just started with java and i need help with my school project, this is it so far: import java.util.*; public...!"); mathcount = mathcount + 1; }else{ System.out.println 

Java Beginners

Help Me in My Java Work
Help Me in My Java Work  Can you help me please... Write a Java... of the GradeClassifier√Ę‚?¨‚?Ęs input and output for valid data: Example of GpaCalculator√Ę‚?¨‚?Ęs output for valid input : Enter a mark between √Ę‚?¨Ň?0√Ę‚?¨¬ 

Java Beginners

help me
the order, Fourth button is Find length of text. and there are panels. Please help me. i want to write the code on this program. please share ur idea.   ...help me  Dear sir/medam i would like to know how to use the java 

Free Magazine

Tips & Tricks
starts to get the behavior of splash screen. But to get the output, Java run time...Tips & Tricks           Splash Screen in Java 6.0 Splash screens 

Java Beginners

Redirecting the console output into a file in Java
to redirect the output of the console to a text file. i used your tutorial, but it's not working for me. Could you please help for this code. [CODE] import...Redirecting the console output into a file in Java  Hi, i coded 

Java Beginners

Java Print the all components
Java Print the all components  This is my code. Please tell me...(f1.txtleave.getText()); if(l<=1) { leave="0"; } else { Calendar... Architecture")) images=new ImageIcon("TWA.jpg"); else 

Java-Tutorials

input output
Input And Output       Introduction The Java I/O means Java Input/Output and is a part of java.io package. This package has a InputStream and OutputStream. Java 

Java Beginners

GUI 2 - Java Beginners
GUI 2  How can I modify this code? Please give me a GUI...;GUI Example");pack();show();}public void actionPerformed(ActionEvent event...();}}This will help you out..  Brilliant! The keyEvent works, but the modified code 

JSP Servlet Questions

help me in solving this error
help me in solving this error  Hello, i have installed tomcat 6.0, i... that problem may be in your code. So please post your code. Thanks   Hello Friend, It seems that problem may be in your code. So please post your code. Thanks 

Java Beginners

Help me - Java Beginners
Help me  please help me in writing a program in java "A student has a name,roll no., class, home address, date of birth. First dessigne a suitable class for date, write constructor and get and set functions. Then dissign a class 

Java Beginners

Component gui - Java Beginners
Component gui  Can you give me an example of Dialog in java Graphical...; //Display their average in a dialog box...); } } ---------------------------------------------- Please visit for more information. http 

Swing AWT

please convert for me this code to GUI - Swing AWT
please convert for me this code to GUI    THE CODES ARE BELOW...; } else screen.displayMessageLine( "\nInvalid account Nummber or PIN, Please... account."+ "\n\n please choose a smaller amount."); } } else 

Java Beginners

Help me - Java Beginners
Help me  I m using session in my project session is activated and admin_home.jsp page will be display but data r not displayed plz guide what is incorrect my code 

Java Interview Questions

Convert the code to GUI ??
Convert the code to GUI ??  hi >> can anyone help me to conver this code to GUI ?? /** * @(#)RegistorClass.java * *. * @author... // Input/Output operations. private final int READ = 10; private final int 

Java Interview Questions

what are the components of java platform ?
what are the components of java platform ?  what are the components of java platform ? plz if any1 perfectly know help me to override my conflicts.plz explain briefly 

Java Beginners

help me for doing project - Java Beginners
help me for doing project  i am handling the project that "email... the email headers and how to display the port and user's information please help me thanks in advance who are going to help me bhanukiran 

Swing AWT

please convert for me this code to GUI - Swing AWT
please convert for me this code to GUI  THE CODES ARE BELOW, CLASS...) { currentAccountNumber=accountNumber; } else screen.displayMessageLine( "\nInvalid account Nummber or PIN, Please try again."); } private void 

Java Beginners

help me .. Java
help me .. Java  ReadStudentsData that takes as parameters an array... of students. It should determine and display the students‚?? names who got... and the number of students. It should determine and display the students‚?? names who 

Java Beginners

help me - Java Beginners
help me   i want to create a login form in java with jdbc connection in ist form there will two label for passworrd and user name and two button..."); } else{ JOptionPane.showMessageDialog(null,"Incorrect login or password","Error 

JavaMail Questions

sirplz help me - JavaMail
sirplz help me  1.Develop multi-threaded echo server and a corresponding GUI client in Java 

Java Beginners

Please help me to solve these programs in Python - Java Beginners
Please help me to solve these programs in Python  1. Write a program that prints an n-level stair case made of text. The user should choose the text...(); } } } -------------------------------- read for more information, http://www.roseindia.net/java 

Java Beginners

hi.. please give me a java coding for the following question
hi.. please give me a java coding for the following question  Body... and display the BMI. Note that one pound is 0.45359237 kilograms and one inch is 0.0254 meters. (using GUI 

Java Beginners

to all Experts.. please help me. im using a Jcreator. - Java Beginners
to all Experts.. please help me. im using a Jcreator.  3. Write a program that asks the user to enter a word. The program will then repeat word for as many times as it has characters: Enter a word: ILOVEU ILOVEU 

Java Beginners

LOOP PROGRAM - Java Beginners
LOOP PROGRAM  Hi all, Someone please help this code. I need a Java program that uses looping to toss a coin over and over until it comes up head...++; } else{ faceName = "Tails"; countT++; } return faceName 

Java Beginners

loop
loop  strong textHello can someone help me with this problem,I need to output the following code using a loop the code is as follows with the user..." CODE:"K19" QUANTITY:"1" CODE:"XX"   import java.util.*; class Output 

Java Beginners

Load function ***PLEASE HELP
Load function ***PLEASE HELP   Hi I am writing a program that tracks... LOAD implementations. Thank you so much for your help. I really need help to get this done as this project is due on monday for me. My code right now looks 

Java Beginners

java help
and then print their corresponding letter grades. Please notify me in your output...java help   Write a Java program that does the following: 1.Creates...?? and ‚??Susan‚?? of the grade class. Creates appropriate display methods 

Java Beginners

if else condition - Java Beginners
if else condition  Please explain the if else condition in Java programming language 

Java Beginners

PLEASE Help me write a Java program which will store, manipulate, and print student registration information.
PLEASE Help me write a Java program which will store, manipulate, and print..., ADDRESS AND ADMISSIONS CLASS PLEASE HELP!!! Write a Java program which...Ę Displaying list of all students that were dropped from the course The output must 

Java Beginners

plz help me - Java Beginners
plz help me  Deepak I can write a sessioon code plz help me admin_home.jsp page is display but data is not disply plz help me what is wrong 

Java Beginners

output java - Java Beginners
. This link will help you . Please visit : http://www.roseindia.net/java/master...; } a. what is the output of the ff. java statement:? i. System.out.println (secret...output java  public static int secret(int one) { int i; int 

Java Beginners

how to save a gui form in core java
how to save a gui form in core java  please help me i am java beginner how to save a jframe containing jtable and panels in java thank you 

Advertisements Advertisements
 

 

 

DMCA.com