473,387 Members | 1,711 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Need help cannot figure out where I made the error.

Need help cannot figure out where I made the error.
--------------------------------------------------------------------------------

Can someone view what I have, I need help I cannot figure out where I went wrong.

Thanks


/* Jose N. Ramirez
CS151

This program will key you a brief overview of how

Java uses the new Scanner class to accept integers

entered then adds them by the user via the keyboard and assigns

them to a primitive variable. */





import java.util.*;



public class Math223

{





public static void main( String args[] )

{



int number1; // first number to add

int number2; // second number to add

int number3; // third number to subtract





Scanner scannerObject =new Scanner(System.in);



System.out.println("This program will add two integers then subtract the third");

System.out.println("together and output the product.\n");



System.out.println("Enter the first integer using the keyboard");



/* This statement assigns the first integer entered by the

user to the scannerObject named number1 */

number1=scannerObject.nextInt();





System.out.println("\n");

System.out.println("Now enter the second integer.");



/* This statement assigns the second integer entered by the

user to the scannerObject named number2 */

number2=scannerObject.nextInt();



System.out.println("You entered "+number1+" and "+number2+" and "-number3" ");

System.out.println("\n");



/*This statement multiplies the integers entered by the

user together and assigns the result to primitve variable

named product.*/

int product = number1 + number2 - number3;





/*This statement outputs the numbers the user enters and

the results obtained by adding them together then subtracting the third number.*/



System.out.println("The product of "+number1+" + "+number2+" - "-number3" ");

System.out.println(" is "+product+"\n\n\n");







} // end method main



} // end of Math223 class
Nov 15 '06 #1
2 1699
r035198x
13,262 8TB
Need help cannot figure out where I made the error.
--------------------------------------------------------------------------------

Can someone view what I have, I need help I cannot figure out where I went wrong.

Thanks


/* Jose N. Ramirez
CS151

This program will key you a brief overview of how

Java uses the new Scanner class to accept integers

entered then adds them by the user via the keyboard and assigns

them to a primitive variable. */





import java.util.*;



public class Math223

{





public static void main( String args[] )

{



int number1; // first number to add

int number2; // second number to add

int number3; // third number to subtract





Scanner scannerObject =new Scanner(System.in);



System.out.println("This program will add two integers then subtract the third");

System.out.println("together and output the product.\n");



System.out.println("Enter the first integer using the keyboard");



/* This statement assigns the first integer entered by the

user to the scannerObject named number1 */

number1=scannerObject.nextInt();





System.out.println("\n");

System.out.println("Now enter the second integer.");



/* This statement assigns the second integer entered by the

user to the scannerObject named number2 */

number2=scannerObject.nextInt();



System.out.println("You entered "+number1+" and "+number2+" and "-number3" ");

System.out.println("\n");



/*This statement multiplies the integers entered by the

user together and assigns the result to primitve variable

named product.*/

int product = number1 + number2 - number3;





/*This statement outputs the numbers the user enters and

the results obtained by adding them together then subtracting the third number.*/



System.out.println("The product of "+number1+" + "+number2+" - "-number3" ");

System.out.println(" is "+product+"\n\n\n");







} // end method main



} // end of Math223 class
You forgot to read in the third number.
Nov 15 '06 #2
try this
Expand|Select|Wrap|Line Numbers
  1.     package com.test;
  2.  
  3.     /* Jose N. Ramirez
  4.      CS151
  5.  
  6.      This program will key you a brief overview of how
  7.  
  8.      Java uses the new Scanner class to accept integers
  9.  
  10.      entered then adds them by the user via the keyboard and assigns
  11.  
  12.      them to a primitive variable. */
  13.  
  14.     import java.util.*;
  15.  
  16.     public class Math223
  17.  
  18.     {
  19.  
  20.     public static void main( String args[] )
  21.  
  22.     {
  23.  
  24.  
  25.  
  26.     int number1; // first number to add
  27.  
  28.     int number2; // second number to add
  29.  
  30.     int number3; // third number to subtract
  31.  
  32.  
  33.  
  34.  
  35.  
  36.     Scanner scannerObject =new Scanner(System.in);
  37.  
  38.  
  39.  
  40.     System.out.println("This program will add two integers then subtract the third");
  41.  
  42.     System.out.println("together and output the product.\n");
  43.  
  44.  
  45.  
  46.     System.out.println("Enter the first integer using the keyboard");
  47.  
  48.  
  49.  
  50.     /* This statement assigns the first integer entered by the
  51.  
  52.     user to the scannerObject named number1 */
  53.  
  54.     number1=scannerObject.nextInt();
  55.  
  56.  
  57.  
  58.  
  59.  
  60.     System.out.println("\n");
  61.  
  62.     System.out.println("Now enter the second integer.");
  63.  
  64.  
  65.  
  66.     /* This statement assigns the second integer entered by the
  67.  
  68.     user to the scannerObject named number2 */
  69.  
  70.     number2=scannerObject.nextInt();
  71.  
  72.  
  73.  
  74.     System.out.println("You entered "+number1+" and "+number2+" and "+number3);
  75.  
  76.     System.out.println("\n");
  77.  
  78.  
  79.  
  80.     /*This statement multiplies the integers entered by the
  81.  
  82.     user together and assigns the result to primitve variable
  83.  
  84.     named product.*/
  85.  
  86.     int product = number1 + number2 - number3;
  87.  
  88.  
  89.  
  90.  
  91.  
  92.     /*This statement outputs the numbers the user enters and
  93.  
  94.     the results obtained by adding them together then subtracting the third number.*/
  95.  
  96.  
  97.  
  98.     System.out.println("The product of "+number1+" + "+number2+" - "+number3);
  99.  
  100.     System.out.println(" is "+product+"\n\n\n");
  101.  
  102.  
  103.  
  104.  
  105.  
  106.  
  107.  
  108.     }
  109.     }
  110.  
-number3" " was used at two places and } (at end)was missing
try eclipse IDE these errors wont be any problem to find
Nov 15 '06 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: simon | last post by:
Hello All, I have an ASP application that works perfectly on our development server, but when we moved the app to our test server, I got the following error message at the line where I do...
0
by: Kyle Goetz | last post by:
hey, i'm new to mySQL...this meaning that i have tried ~10000 times to install it and get it working over the past few weeks...and it always gives me the same error (scroll further down to see it)...
1
by: Paul | last post by:
Hello, I know there are other messages concerning this error message, but they all look so confusing to me. I have an application that uses an Access database. No problems with permissions....
7
by: George Jordanov Ivanov | last post by:
Folks, I have to design the WSDL files of a bunch of XML Web Services. But, unfortunately, I am not very keen on writing the WSDL file line by line, and moreover be aware of the whole standard...
2
by: cmt | last post by:
Greetings! I have an asp page that writes out a URL that points to files on a network drive. It has been working fine up until a week ago. I haven't made any changes to the server or code, so...
9
by: pic078 via AccessMonster.com | last post by:
I need serious help - I have a frontend/backend Access database (2 MDE Files) that remains stuck in task manager after exiting the application - you can't reopen database after exiting as a result...
10
by: =?Utf-8?B?UmF2aSBTaGFua2Fy?= | last post by:
Hi, I have a requirement where I need to call methods written in VB.Net from a C++ code. I have been going crazy reading various articles on the net w.r.t interop and marshalling but an more...
5
by: Chuck Anderson | last post by:
I run Apache 2.0.55, and Php (both 4.4.1 and 5.2.5) on my home PC (Windows XP). One of the scripts that I run daily needs to access a secure URL (https://..............). When I am running Php4,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.