473,890 Members | 1,760 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Need help cannot figure out where I made the error.

3 New Member
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.prin tln("This program will add two integers then subtract the third");

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



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



/* This statement assigns the first integer entered by the

user to the scannerObject named number1 */

number1=scanner Object.nextInt( );





System.out.prin tln("\n");

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



/* This statement assigns the second integer entered by the

user to the scannerObject named number2 */

number2=scanner Object.nextInt( );



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

System.out.prin tln("\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.prin tln("The product of "+number1+" + "+number2+" - "-number3" ");

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







} // end method main



} // end of Math223 class
Nov 15 '06 #1
2 1733
r035198x
13,262 MVP
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.prin tln("This program will add two integers then subtract the third");

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



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



/* This statement assigns the first integer entered by the

user to the scannerObject named number1 */

number1=scanner Object.nextInt( );





System.out.prin tln("\n");

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



/* This statement assigns the second integer entered by the

user to the scannerObject named number2 */

number2=scanner Object.nextInt( );



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

System.out.prin tln("\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.prin tln("The product of "+number1+" + "+number2+" - "-number3" ");

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







} // end method main



} // end of Math223 class
You forgot to read in the third number.
Nov 15 '06 #2
maverick19
25 New Member
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
2762
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 Response.Redirect: //messages begin---------------------------- Response object error 'ASP 0156:80004005' Header Error /ChkBlkAccess.asp, line 47
0
8344
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) despite following the manual's windows installation exactly i have version 4.0.13 for windows and i used the installer once i was done, i followed the instructions in the manual exactly i have no firewall running
1
4717
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. I made a windows service of that application. I choose 'ServiceAccount.LocalService' in the ProjectInstaller (VS.NET) which means Anonymous User.
7
7006
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 specification in details. I will be very happy if there is a visual tool, which can do this for me. Does anyone know such kind of tool (if it is free, this is going to be awesome)? Thanks in advance. Regards,
2
2291
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 I can't figure out why the script suddenly stopped working. I have verified that the files do exist, and that the paths are
9
3952
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 - I have read every post out there and spent hours trying to figure out the problem with no success whatsoever - I have constrained the problem to one form however, and I think it's hiding somewhere in my code associated with this form, which is...
10
5781
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 confused now that before. the signature I need to conform in the VB.Net DLL is int MyAppInitFunc(int argc, char** argv) To this extent I have tried the following
5
7976
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, it can open the file. However, when I run Php5 I (now) get this error message: "Unable to find the wrapper "https" - did you forget to enable it when you configured PHP?" This is new. Last time I messed with this, I merely got:
0
11212
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10899
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10446
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9614
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
8004
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7154
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
6032
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4655
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4255
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.