Hi there,I am stuck here.The question ask to Write an application for a university admissions office. Prompt the user for a
student’s High School Grade Point and an admission test score
(value from 0 to 100). Print the message “Accept” if the student has any of the
following:
A grade point of 3.0 or above and an admission test score of at least 60.
A grade point below 3.0 and an admission test score of at least 80.
If student does not meet either of the qualification criteria, print “Reject”.

I manage to do that below are the codes.

import javax.swing.*;

class apple{	   
	public static void main(String[] args){
		
		double gp = 4.0;
		int ts = 100;
		
		
		
                gp = doubleValue(
                        JOptionPane.showInputDialog(
                             null, "Enter Grade point: "));
                ts = Integer.parseInt(
                        JOptionPane.showInputDialog(
                             null, "Enter Test score: "));
	
                if (gp >= 3.0 && ts >= 60){
                JOptionPane.showMessageDialog(null, "Accept");
                } else if (gp <= 3.0 && ts >= 80){
                	JOptionPane.showMessageDialog(null, "Accept");
                }else {
                	JOptionPane.showMessageDialog(null, "Reject");
                
                }
                	
                }

	private static double doubleValue(String showInputDialog) {
		return 0;
	}
                }

But when to Modified it , So that if a user enters a grade point under 0 or over 4.0, or a test score under 0 or over 100, an error message appears instead of the“Accept” or “Reject” message.

So far what I try the below code but Fail. Am i missing something?

import javax.swing.*;
public class apples {

	
		public static void main(String[] args){
			
			double gp = 4.0;
			int ts = 100;
			
			
			
	                gp = doubleValue(
	                        JOptionPane.showInputDialog(
	                             null, "Enter Grade point: "));
	                ts = Integer.parseInt(
	                        JOptionPane.showInputDialog(
	                             null, "Enter Test score: "));
		
	                if (gp >= 3.0 && ts >= 60){
	                JOptionPane.showMessageDialog(null, "Accept");
	                } else if (gp <= 3.0 && ts >= 80){
	                	JOptionPane.showMessageDialog(null, "Accept");	
	                } else if (gp <= 0.0 && ts <= 0){
	                	JOptionPane.showMessageDialog(null, "Invalid Result");
	                } else if (gp > 4.0 && ts > 100){
	                	JOptionPane.showMessageDialog(null, "Invalid Result");
	                }else {
	                	JOptionPane.showMessageDialog(null, "Reject");
	                	
	                
	                }
	                	
	                }

		private static double doubleValue(String showInputDialog) {
			return 0;
		}
		}

Can you please advise me how to modified it, I did try google and daniweb,but notting much . Thanks in advance

oh by the way just Ignor my

public class

sorry misread!

I think your tests for invalid input should be || not && - ie it's invalid if either criterion is not met. And maybe you should put these tests before the accept/reject tests, so that a gp of 9 and a ts of 200 is shown as invalid rather than pass.
And doubleValue(...) looks a bit incomplete! Have a look at Double.parseDouble(...) in the API.

Hi James,
I did as you told to change || but the answer is same.I dont know where is the mistake.

pls help me to my program

I need to see the full program

Example:
my Input is : 4

The output should be: 288

Because
1^2+2^2+3^3+4^4

1+4+27+256=288

I dont know How to use exponent in Java w/o using math.pow..and I dont know how to add all the sums.please help me.

pls help me to my program

I need to see the full program

Example:
my Input is : 4

The output should be: 288

Because
1^2+2^2+3^3+4^4

1+4+27+256=288

I dont know How to use exponent in Java w/o using math.pow..and I dont know how to add all the sums.please help me.

Hi Lance Have a look here maybe you can have a better understanding .

Joss - did you read the last line of my previous post?
Lance - do not hijack other people's threads. Start a new one for your problem.

Joss - did you read the last line of my previous post?
Lance - do not hijack other people's threads. Start a new one for your problem.

Dear James,
are you refering to "Double.parseDouble(" yes i just notice it.
I am still googling around and reading other post how to solve my problem .

Joss

sory sir james,but i'm just a new member here so i dont know how to post a new threads

sory sir james,but i'm just a new member here so i dont know how to post a new threads

On the main forum page http://www.daniweb.com/forums/forum9.html click where it says "Want to start a new topic discussion? - Click here to start a new thread"

sory sir james,but i'm just a new member here so i dont know how to post a new threads

Hi Lance, Its Easy Just click on This Link

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.