Hello, i am just starting with Java and one of the programs is, to make a long story short, evaluate a computers power (pretend). you put in how many applications you want to run, what operating system and what power your computer is and it tells you whether you can run it or not. if not between 1 and 20, invalid entry. if not windows xp, vista or windows 7, invalid entry, in a nutshell. the problem im having is it is spitting out "invalid entry" and the result at the same time. run the program and youll see what i mean. thanks your your help!!

import java.util.Scanner;

public class System {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int application = 0;
		double power = 0.0;
		String operatingsystem = "";

		System.out.print("Type the number of applications you will be running:");
		app = scan.nextInt();
		
		scan.nextLine();

		if (application > 20) {
			System.out.print("Invalid Entry");
		} else if (application == 0) {
			System.out.print("Enough Power");
		} else if (application < 0) {
			System.out.print("Invalid Entry");
		}

		if (0 < application && application <= 20) {
			System.out.print("Type the Operating System you will be using:");
			operatingsystem = scan.nextLine();
		}

		if (operatingsystem.equals("Windows XP")) {
			System.out.print("Type the power you have on that system:");
			power = scan.nextDouble();
		}

		if (application == 1 && power > 300) {
			System.out.print("Enough Power");
		} else if (application == 2 && power > 500) {
			System.out.print("Enough Power");
		} else if (power <= 300) {
			System.out.print("Invalid Entry");
		}
		if (2 < application && application <= 20) {
			if (power > (((application - 2) * 50) + 500)) {
				System.out.print("Enough Power");
			} else {
				System.out.print("Can Not Run");
			}
		}

		if (operatingsystem.equals("Vista")) {
			System.out.print("Type the power you have on that system:");
			power = scan.nextDouble();
		}

		if (application == 1 && power > 800) {
			System.out.print("Enough Power");
		} else if (application == 2 && power > 1000) {
			System.out.print("Enough Power");
		} else if (power < 800) {
			System.out.print("Invalid Entry");
		}
		if (2 < application && application <= 20) {
			if (power > (((application - 2) * 50) + 1000)) {
				System.out.print("Enough Power");
			} else {
				System.out.print("Can Not Run");
			}
		}

		if (operatingsystem.equals("Windows 7")) {
			System.out.print("Type the power you have on that system:");
			power = scan.nextDouble();
		}
		if (application == 1 && power > 500) {
			System.out.print("Enough Power");
		} else if (application == 2 && power > 800) {
			System.out.print("Enough Power");
		} else if (power < 500) {
			System.out.print("Invalid Entry");
		}
		if (2 < application && application <= 20) {
			if (power > (((application - 2) * 50) + 800)) {
				System.out.print("Enough Power");
			} else {
				System.out.print("Can Not Run");
			}
		}
	}
}

Why would you read in the user's choice into a variable called "app" but then check to see if a variable called "application" is greater than 20. There is your first mistake right there. Besides, you already know that application = 0 since you just declared it and never changed it.

wow, that and some editing took care of it haha of course i miss the obvious thing, thank you

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.