Skip to main content



      Home
Home » Newcomers » Newcomers » Half of program print problem(Only half of my program is printing!)
icon8.gif  Half of program print problem [message #1708598] Thu, 17 September 2015 19:03 Go to next message
Eclipse UserFriend
Hi,
I'm creating a program for class and have done everything as it's said in the book. At first I had the keyboard should never be closed problem, but after a quick email to my professor it worked. Now only half of my program will print, I really really need help, but I don't want to ask my professor because I've been bothering him all day. Embarrassed If you guys could help me before midnight central time that would be amazing, listed below is the what I have so far on the program.

import java.util.Scanner;

public class Program1Segura
{
public static void main(String[] args)
{
System.out.println("Hello out there.");
System.out.println("I will add two number for you.");
System.out.println("Enter two whole numbers on a line:");

int n1, n2;

Scanner keyboard = new Scanner(System.in);
n1 = keyboard.nextInt(35);
n2 = keyboard.nextInt(20);

System.out.println("The sum of those two numbers is");
System.out.println(n1 + n2);
keyboard.close();
}
}

Any help is greatly appreciated!!
Re: Half of program print problem [message #1708860 is a reply to message #1708598] Mon, 21 September 2015 21:11 Go to previous message
Eclipse UserFriend
I am not sure what the desired output is. Your code runs perfectly except I would make one small change. To let the user actually specify the integers to be added remove the integers from keyboard.nextint();

		System.out.println("Hello out there.");
		System.out.println("I will add two number for you.");
		System.out.println("Enter two whole numbers on a line:");

		int n1, n2;

		Scanner keyboard = new Scanner(System.in);
		n1 = keyboard.nextInt();
		n2 = keyboard.nextInt();

		System.out.println("The sum of those two numbers is");
		System.out.println(n1 + n2);
		keyboard.close();
Previous Topic:Code Template Question (Auto Generated Method Stub)
Next Topic:Eclipse Luna does not find references to Java elements
Goto Forum:
  


Current Time: Fri Jul 04 08:49:20 EDT 2025

Powered by FUDForum. Page generated in 0.33737 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top