Wrox Programmer Forums
|
Java Basics General beginning Java language questions that don't fit in one of the more specific forums. Please specify what version.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Java Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 13th, 2006, 10:42 AM
Registered User
 
Join Date: May 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Mohsin116
Default error with code

Can some one help me with this code. their is a error with the scanner
if someone can help


import java.util.*;
import java.io.*;

class CalculatesPay{
public static void main(String args[])
{
float Totalpay,PayRate,HoursWorked;
scanner in = new Scanner(System.in);
System.out.println(">>>>Enter hourly pay rate<<<<");
PayRate=scanner.nextFloat();
System.out.println(">>>>Enter number of hours worked ?<<<<");
HoursWorked=scanner.nextFloat();
Totalpay = PayRate * HoursWorked;
System.out.println("Total weekly pay is = £"+Totalpay);
         }
     }









 
Old May 14th, 2006, 07:40 AM
Authorized User
 
Join Date: Mar 2006
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default

What error message do you get? You haven't initialised the scanner variable. What kind of object is Scanner and what package is it in?






Similar Threads
Thread Thread Starter Forum Replies Last Post
Error in Code NadAf BOOK: Ivor Horton's Beginning Visual C++ 2005 0 February 18th, 2008 11:16 PM
Code error reverand Excel VBA 1 November 15th, 2006 02:08 AM
Code error??? emyr BOOK: Beginning Java 2 1 October 31st, 2006 05:47 PM
Code error!?!? Brian Campbell BOOK: Beginning PHP4/PHP 5 ISBN: 978-0-7645-4364-7; v5 ISBN: 978-0-7645-5783-5 3 November 26th, 2004 07:47 PM
Error displayed with error trap code stoneman Access 4 February 28th, 2004 02:53 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.