Results 1 to 3 of 3
Thread: Problems printing if statements
- 11-24-2010, 02:57 AM #1
Member
- Join Date
- Nov 2010
- Posts
- 5
- Rep Power
- 0
Problems printing if statements
Thank you for anyone who takes a look at this for me.
I have been working on it all day. I can get it to compile, but I can not get it to print my if statements. I am attaching what I have got. Any help would be wonderful.
Java Code:import javax.swing.JOptionPane; public class CollegeAdmissions2 { public static String accepted(double gpa, double entScore) { String decision; if(gpa >= 3.0 && entScore >= 60 || entScore >= 85 && gpa >= 0) decision = ("We are pleased to accept you at our school."); else decision = ("I am sorry, based on your scores," + "\n We cannot accept you at this time"); if(!(gpa > 0 && gpa <= 4.0 && entScore >= 0 && entScore <= 100)) decision = ("You have entered invalid data"); return decision; } public static void main(String[] args) { double gpa; double entScore; gpa = Double.parseDouble(JOptionPane.showInputDialog (null,"Please enter your grade point average:")); entScore = Double.parseDouble(JOptionPane.showInputDialog (null,"Please enter your entrance score:")); System.out.println("Welcome the Admissions Department"); System.out.println("Your gradepoint average is: " + gpa); System.out.println("Your entrance score is: " + entScore); String decision; decision = accepted(gpa, entScore); } }Last edited by diamondeyes; 12-16-2010 at 08:56 PM.
- 11-24-2010, 03:20 AM #2
If I understand the issue correctly, you're just looking to add a System.out.println(decision); after decision = accepted(gpa, entScore);.
(PS: In the future, please wrap code in [code][/code] tags.)
- 11-24-2010, 03:55 AM #3
Member
- Join Date
- Nov 2010
- Posts
- 5
- Rep Power
- 0
Similar Threads
-
Problems with printing variables and inserting data into array
By coltragon in forum New To JavaReplies: 6Last Post: 11-03-2010, 02:33 PM -
Problem to stop printing statements
By Rekuta in forum New To JavaReplies: 1Last Post: 05-13-2010, 06:05 PM -
Problems saving a file and printing its contents.
By gth05 in forum New To JavaReplies: 3Last Post: 12-03-2009, 10:05 PM -
Printing ranges of numbers using if/else statements
By russbuss106 in forum New To JavaReplies: 8Last Post: 03-05-2009, 05:03 AM -
Problems with packages (import statements)
By ai_2007 in forum Advanced JavaReplies: 1Last Post: 06-29-2007, 11:57 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks