Results 1 to 6 of 6
Thread: What's wrong with my code/ :-/
- 10-11-2012, 04:19 PM #1
Member
- Join Date
- Oct 2012
- Posts
- 24
- Rep Power
- 0
What's wrong with my code/ :-/
I keep trying to program a code to count the 6 digits of a si-digit number but I keep getting a (cannot find symbol) error. Can someone point out were I am going wrong?
Java Code:import java.util.Scanner; public class Integer { public static void main(String[]args) { int Number; Scanner console = new Scanner (System.in); System.out.print("Enter six-figure digit: "); Number = Integer.parseInt(console.nextLine()); int Result; Result = (Number /100000); Result = Result + ((Number % 100000) / 10000); Result = Result + ((Number / 1000)); Result = Result + ((Number % 1000) / 100); Result = Result + (Number / 10); Result = Result + ((Number % 10) / 1); System.out.print("The sum of the six-figure digit is: " + Result); } }Last edited by Tolls; 10-11-2012 at 04:45 PM.
- 10-11-2012, 04:23 PM #2
Senior Member
- Join Date
- Aug 2011
- Posts
- 116
- Rep Power
- 0
Re: What's wrong with my code/ :-/
You have named your scanner "console", but you do not use it anywhere.
http://docs.oracle.com/javase/1.5.0/...l/Scanner.html
- 10-11-2012, 04:45 PM #3
Moderator
- Join Date
- Apr 2009
- Posts
- 10,484
- Rep Power
- 16
Re: What's wrong with my code/ :-/
Please give us the full error and where it occurs.
(I've corrected your close code tag typo)
Note that console is used in this line:
and even if it wasn't that would not generate a "cannot find symbol" compiler error.Java Code:Number = Integer.parseInt(console.nextLine());
Please do not ask for code as refusal often offends.
- 10-11-2012, 04:48 PM #4
Senior Member
- Join Date
- Aug 2011
- Posts
- 116
- Rep Power
- 0
- 10-11-2012, 05:14 PM #5
Moderator
- Join Date
- Apr 2009
- Posts
- 10,484
- Rep Power
- 16
Re: What's wrong with my code/ :-/
Oh right, but not using a variable will not give a "cannot find symbol" compiler error, so unless something else has been edited then that won't be the problem.
Please do not ask for code as refusal often offends.
- 10-13-2012, 04:51 PM #6
Member
- Join Date
- Oct 2012
- Posts
- 11
- Rep Power
- 0
Re: What's wrong with my code/ :-/
Hello there I am new to Java and have been getting some help but I cant figure out why I am getting errors please help
import java.util.Scanner;
class VegetablesLab
{
public static void main( String[] args )
{
int apples = 30;
int oranges = 45;
int turnips = 70;
double strawberries = 2.30;
double potatoes = 3.25;
double carrots = 1.25;
String name = "";
String address = "";
String ccnum ="";
String dob = "";
String email = "";
String email2 = "";
String grocery1 = "";
String grocery2 = "";
String grocery3 = "";
String amount1 = "";
String amount2 = "";
String amount3 = "";
Scanner input = new Scanner( System.in );
System.out.println( "Enter your Full Name Please:" );
name = input.nextLine();
System.out.println( name );
System.out.println("Enter your Address please");
address = input.nextLine();
System.out.println( address );
System.out.println("Enter your Credit Card number please:");
ccnum = input.nextLine();
System.out.println( ccnum );
System.out.println("Enter your dob:");
dob = input.nextLine();
System.out.println( dob );
System.out.println("Enter your email address:");
email = input.nextLine();
System.out.println( email );
System.out.println("Re-enter your email address:");
email2 = input.nextLine();
System.out.println( email2 );
if( email == email2)
System.out.println("Enter first grocery item:");
amount1();
grocery1 = input.nextLine();
System.out.println(firstgrocery);
System.out.println("Enter second grocery item:");
amount2();
grocery2 = input.nextLine();
System.out.println(secondgrocery);
System.out.println("Enter third grocery item:");
amount3();
grocery3 = input.nextLine();
System.out.println(thirdgrocery);
System.out.println("Total cost");
}
}
Similar Threads
-
What is wrong with my code?
By tweetychirpy in forum Threads and SynchronizationReplies: 4Last Post: 12-23-2011, 05:16 PM -
What's wrong with my code?
By Johanis in forum New To JavaReplies: 1Last Post: 10-30-2011, 12:38 PM -
What is wrong with my code?!
By new2java2009 in forum New To JavaReplies: 2Last Post: 04-17-2010, 08:01 PM -
pls tell wat wrong with my code???
By low224 in forum New To JavaReplies: 13Last Post: 01-11-2009, 07:40 AM -
what is wrong with this code
By masaka in forum New To JavaReplies: 5Last Post: 04-16-2008, 08:27 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks