Need help with solving the (basic) programming error

I'm reaaaaaaaaaally new to Java and programming in general. I've been glancing through my older brother's old stuff (he's back at Uni!) and I've taken an interest.
Anyways, so I'm trying to finish this really simple program cause I wanna wow some friends ("wow" = "haha we've done this before a gazillion times") but I can't seem to solve this "incompatible lines" bug in the code, specifically line 24. I've been looking at it for exactly 4 hours!! Programming in Java 1.6.
Thanks for the help!! :)
import java.util.*;
import java.util.Scanner;
public class LuigisPizzaProgram {
     public static void main(String args[]) {
     System.out.println("Luigi's Pizza");
     System.out.println("-------------------------------------------");
     System.out.println(" a(SML) b(MED) c(LRG)");
     System.out.println("1. Cheese 5.00 7.50 10.00");
     System.out.println("2. Pepperoni 5.75 8.63 11.50");
     System.out.println("3. Combination 6.50 9.75 13.00");
     System.out.println("4. Vegetarian 7.25 10.88 14.50");
     System.out.println("5. Meat Lovers 8.00 12.00 16.00");
     System.out.println(" ");
     System.out.println("What kind of pizza do you want?");     
     int kind = new Scanner(System.in).nextInt();
     System.out.println(kind);
     System.out.println("What size of pizza do you want?");
     char size = new Scanner(System.in).nextLine();
     System.out.println(size);
     }

Having said that, it is nontraditional to use Scanner like you are using it. There is no way to reuse it in order to get more input. Better would be something like:
        System.out.println("What size of pizza do you want?");
        Scanner scan = new Scanner(System.in);  // create the scan variable
        String size = scan.nextLine(); // now use the scan variable
        System.out.println(size);Also, when posting your code, please use code tags so that your code will be well-formatted and readable. To do this, place the tag [code] at the top of your block of code and the tag [/code] at the bottom, like so:
[code]
  // your code block goes here.
[/code]good luck, pete

Similar Messages

  • I would appreciated any help with solving the IOS 5 Error message -50

    Did you expereince the same message? If so, if you can help me I would appreciate it. iTunes is uodated but when i ty to update my phone to IOS 5 I get the above error. Thanks for looking.

    I am also having this issue, upgraded to ios5 however when attempting to back up my phone i get the same -50 error message.
    iPhone 3G-S 16gb.

  • Need help to trace the place where error occuring in Web UI of type System

    Hi All,
    Need help to trace the place where error occurring in Web UI of type System error,
    this error coming while saving the corporate account creation,
    error message description : - System error: Interruption in Routine READ TABLE GT_CHAR_VAL, CHAR_NAME = PVTLTD_CLEAN_SEGMENT
    System error: Interruption in Routine READ TABLE GT_CHAR_VAL, CHAR_NAME = PVTLTD_CLEAN_CLASS-CP
    thanking you.
    Best Regards,
    VijHyd

    Hi Nagaraj,
    See that the mandatory SICF setting are enabled or Active in the SICF Services.  Follow the steps as below:-
    Enter the TCode SICF
    Execute the same for Hierarchy Type SICF.
    Check the following SAP Note 1295006.
    If every thing is Active then, the IC Agent role will open.
    Still if it is not opening Let me know.
    regards,
    Sarangamath

  • Question: Need help with overcoming the following message:  "Nothing was imported.

    Need help with overcoming the following message:  “Nothing was imported.  The file(s) or folder(s) selection to import did not contain any supported file types, or the files are already in this catalogue”.
    The photos being scanned are old film shots.  They have NOT been previously scanned.  I am using Photoshop Elements 9 software.
    QUESTION:  how do I override this STOP and or circumvent the photo comparison option????
    Thanks for the help. Bob K ---  [email protected]

      Are you scanning as jpeg, tiff or some other format?
    Are you using continuous numbering for files names as by definition scanned files have no exif data.
     

  • Need help with accessing the program.

    I need help with accessing my adobe creative cloud on my windows 8.1 laptop. I have an account but do not have an app. I need this for my online classes. Please help!

    Link for Download & Install & Setup & Activation may help
    -Chat http://www.adobe.com/support/download-install/supportinfo/

  • I need help with TV Capture Card program

    Hello,
    I want to create a JAVA program so I can schedule that the recording with my TV Capture Card begins in x seconds.
    Now to start a recording, you must press Ctrl+M and to stop an recording you must click the mouse.
    How can I realise that a Java application can "press" Ctrl+M. I have to create an timer, that must be do-able... but I don't know how the program can simulate the pressing of Ctrl+M. I also need to know how the Java program can do a mouse click for me to end the recording.
    Thanks in advance for helping me.
    Chris.

    Thank you... I think this was exactly what I needed.

  • I just bought my MacBook Pro 13" and I tried to install an anti virus but then it went into a grey folder with a question mark I need help with restoring the iOS please

    I need help taking out the grey folder with the question mark and I've try everything except the CD thing because my MacBook didn't come with one so I really need help please

    What anti-virus software did you install? Although there's a lot of bad anti-virus software out there, no anti-virus software should cause such a problem. A gray screen with a flashing question mark on a folder means that no bootable system could be found, which means that the system was badly damaged or corrupt. Even installing bad software would not normally cause that, so either there was something badly wrong with the system already or the anti-virus software you tried to install was really, really bad!
    As mende1 says, you need to reinstall the system at this point. After your system is back up and running, read my Mac Malware Guide. If, after reading that, you want anti-virus software, use one of the programms recommended in that guide.

  • Need help with adding the following to a program

    Modify the mortgage program to display the mortgage payment amount. Then, list the loan balance and interest paid for each payment over the term of the loan. The list would scroll off the screen, but use loops to display a partial list, hesitate, and then display more of the list. Do not use a graphical user interface. Insert comments in the program to document the program.
    Currently I am working on adding the following line in bold but getting error expected ";" on line 27
    import java.io.*;
    import java.util.Date;
    import java.text.DecimalFormat;
    public class Mortgage5
    public static void main(String[] args)
    Date currentDate = new Date(); //Date constructor
    DecimalFormat decimalPlaces = new DecimalFormat("$###,###.##");
    //declaring variables
    final double PRINCIPLE = 200000;
    final double INTEREST = .0575/12;
    final double TERM = 12*30;
    //declaring variables
    final double MONTHLY =PRINCIPLE*(INTEREST/(1-Math.pow(1+INTEREST, -TERM)));
    //displaying variables
    System.out.println("\t\t" + currentDate);
    System.out.println("\t\tPrinciple or Loan Amount: " + decimalPlaces.format(PRINCIPLE));
    System.out.println("\t\tInterest Rate: " + (INTEREST));
    System.out.println("\t\tThe Term of Loan (in months): " + (TERM));
    System.out.println("\t\tThe Monthly Payment is: " + decimalPlaces.format(MONTHLY));
    System.out.println("\t\tThe Balence - Your Payment is: " + decimalPlaces.format(PRINCIPLE*INTEREST*TERM)-MONTHLY));
    Any suggestions??? PLEASE

    Ok I figured out the issue now if someone can help me. I need to create a loop for the following:
    The list would scroll off the screen, but use loops to display a partial list, hesitate, and then display more of the list.
    Here is the Program so far.
    import java.io.*;
    import java.util.Date;
    import java.text.DecimalFormat;
    public class Mortgage5
    public static void main(String[] args)
    Date currentDate = new Date(); //Date constructor
    DecimalFormat decimalPlaces = new DecimalFormat("$###,###.##");
    //declaring variables
    final double PRINCIPLE = 200000;
    final double INTEREST = .0575/12;
    final double TERM = 12*30;
    //declaring variables
    final double MONTHLY =PRINCIPLE*(INTEREST/(1-Math.pow(1+INTEREST, -TERM)));
    final double NEWBAL = (PRINCIPLE*INTEREST*TERM) -MONTHLY;
    //displaying variables
    System.out.println("\t\t" + currentDate);
    System.out.println("\t\tPrinciple or Loan Amount: " + decimalPlaces.format(PRINCIPLE));
    System.out.println("\t\tInterest Rate: " + (INTEREST));
    System.out.println("\t\tThe Term of Loan (in months): " + (TERM));
    System.out.println("\t\tThe Monthly Payment is: " + decimalPlaces.format(MONTHLY));
    System.out.println("\t\tThe Balence - Your Payment is: " + decimalPlaces.format(NEWBAL));
    }

  • I need help with a lab from programming.

    I need the following tasks implemented in the code I wrote below. I would really appreciate if someone could achieve this because it would help me understand the coding process for the next code I have to write. Below are the four classes of code I have so far.
    save an array of social security numbers to a file
    read this file and display the social security numbers saved
    The JFileChooser class must be used to let the user select files for the storage and retrieval of the data.
    Make sure the code handles user input and I/O exceptions properly. This includes a requirement that the main() routine does not throw any checked exceptions.
    As a part of the code testing routine, design and invoke a method that compares the data saved to a file with the data retrieved from the same file. The method should return a boolean value indicating whether the data stored and retrieved are the same or not.
    * SSNArray.java
    * Created on February 28, 2008, 9:45 AM
    * To change this template, choose Tools | Template Manager
    * and open the template in the editor.
    package exceptionhandling;
    import java.util.InputMismatchException; // program uses class InputMismatchException
    import org.omg.PortableInterceptor.ORBInitInfoPackage.DuplicateName;
    * @author mer81348
    public class SSNArray
        public static int SOCIAL_SECURITY_NUMBERS = 10;
        private String[] socialArray = new String[SOCIAL_SECURITY_NUMBERS];
        private int socialCount = 0;
        /** Creates a new instance of SSNArray */
        public SSNArray ()
        public SSNArray ( String[] ssnArray, int socialNumber )
            socialArray = ssnArray;
            socialCount = socialNumber;
        public int getSocialCount ()
            return socialCount;
        public String[] getSocialArray ()
            return socialArray;
        public void addSocial ( String index )
            socialArray[socialCount] = index;
            socialCount++;
        public String toString ()
            StringBuilder socialString = new StringBuilder ();
            for ( int stringValue = 0; stringValue < socialCount; stringValue++ )
                socialString.append ( String.format ("%6d%32s\n", stringValue, socialArray[stringValue] ) );
            return socialString.toString ();
        public void validateSSN ( String socialInput ) throws InputMismatchException, DuplicateName
            if (socialInput.matches ("\\d{9}"))
                return;
            else
                throw new InputMismatchException ("ERROR! Incorrect data format");       
    * SSNArrayTest.java
    * Created on February 28, 2008, 9:46 AM
    * To change this template, choose Tools | Template Manager
    * and open the template in the editor.
    package exceptionhandling;
    import java.util.InputMismatchException; // program uses class InputMismatchException
    import java.util.Scanner; // program uses class Scanner
    import org.omg.PortableInterceptor.ORBInitInfoPackage.DuplicateName;
    * @author mer81348
    public class SSNArrayTest
        /** Creates a new instance of SSNArrayTest */
        public SSNArrayTest ()
         * @param args the command line arguments
        public static void main (String[] args)
            // create Scanner to obtain input from command window
            Scanner input = new Scanner ( System.in );
            System.out.printf ( "\nWELCOME TO SOCIAL SECURITY NUMBER CONFIRMER\n" );
            SSNArray arrayStorage = new SSNArray ();
            for( int socialNumber = 0; socialNumber < SSNArray.SOCIAL_SECURITY_NUMBERS; )
                String socialString = ( "\nPlease enter a Social Security Number" );
                System.out.println (socialString);
                String socialInput = input.next ();
                try
                    arrayStorage.validateSSN (socialInput);
                    arrayStorage.addSocial (socialInput);
                    socialNumber++;
                catch (InputMismatchException e)
                    System.out.println ( "\nPlease reenter Social Security Number\n" + e.getMessage() );
                catch (DuplicateName e)
            System.out.printf ("\nHere are all your Social Security Numbers stored in our database:\n");
            System.out.printf ( "\n%8s%32s\n", "Database Index", "Social Security Numbers" );
            System.out.println (arrayStorage);
    * SSNArrayExpanded.java
    * Created on February 28, 2008, 9:52 AM
    * To change this template, choose Tools | Template Manager
    * and open the template in the editor.
    package exceptionhandling;
    import java.util.InputMismatchException;
    import org.omg.PortableInterceptor.ORBInitInfoPackage.DuplicateName;
    * @author mer81348
    public class SSNArrayExpanded extends SSNArray
        /** Creates a new instance of SSNArrayExpanded */
        public SSNArrayExpanded ()
        public SSNArrayExpanded ( String[] ssnArray, int socialNumber )
            super ( ssnArray, socialNumber );
        public void validateSSN ( String socialInput ) throws InputMismatchException, DuplicateName
            super.validateSSN (socialInput);
                int storedSocial = getSocialCount ();
                for (int socialMatch = 0; socialMatch < storedSocial; socialMatch++ )
                    if (socialInput.equals (getSocialArray () [socialMatch]))
                        throw new DuplicateName ();
            return;
    * SSNArrayTestExpanded.java
    * Created on February 28, 2008, 9:53 AM
    * To change this template, choose Tools | Template Manager
    * and open the template in the editor.
    package exceptionhandling;
    import java.util.InputMismatchException; // program uses class InputMismatchException
    import java.util.Scanner; // program uses class Scanner
    import org.omg.PortableInterceptor.ORBInitInfoPackage.DuplicateName;
    * @author mer81348
    public class SSNArrayTestExpanded
        /** Creates a new instance of SSNArrayTest */
        public SSNArrayTestExpanded ()
         * @param args the command line arguments
        public static void main (String[] args)
            // create Scanner to obtain input from command window
            Scanner input = new Scanner ( System.in );
            System.out.printf ( "\nWELCOME TO SOCIAL SECURITY NUMBER CONFIRMER\n" );
            SSNArrayExpanded arrayStorage = new SSNArrayExpanded(); 
            for( int socialNumber = 0; socialNumber < SSNArray.SOCIAL_SECURITY_NUMBERS; )
                String socialString = ( "\nPlease enter a Social Security Number" );
                System.out.println (socialString);
                String socialInput = input.next ();
                try
                    arrayStorage.validateSSN (socialInput);
                    arrayStorage.addSocial (socialInput);
                    socialNumber++;
                catch (InputMismatchException e)
                catch (DuplicateName e)
                    System.out.println ( "\nSocial Security Number is already claimed!\n" + "ERROR: " + e.getMessage() ); 
            System.out.printf ("\nHere are all your Social Security Numbers stored in our database:\n");
            System.out.printf ( "\n%8s%32s\n", "Database Index", "Social Security Numbers" );
            System.out.println (arrayStorage);
    }

    cotton.m wrote:
    >
    That writes creates the file but it doesn't store the social security numbers.True.Thanks for confirming that...
    How do I get it to save?
    Also, in the last post I had the write method commented out, the correct code is:
         System.out.printf ("\nHere are all your Social Security Numbers stored in our database:\n");
            System.out.printf ( "\n%8s%32s\n", "Database Index", "Social Security Numbers" );
            System.out.println ( arrayStorage );
            try
                File file = new File ("Social Security Numbers.java");
                // Create file if it does not exist
                boolean success = file.createNewFile ();
                if (success)
                      PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter("Social Security Numbers.txt")));               
    //                BufferedWriter out = new BufferedWriter (new FileWriter ("Social Security Numbers.txt")); 
                    out.write( "what goes here ?" );
                    out.close ();
                    // File did not exist and was created
                else
                    // File already exists
            catch (IOException e)
            System.exit (0);
    }It still doesn't write.

  • Need help with correcting the select statement

    I have two tables mkt & error.
    The fields of mkt are
    app_id (xxx)
    c_mkt_id
    app_mkt_id
    The fields of error table are
    mkt_id
    intr_id (its in format xxx.yyy or xxx)
    xyz
    abc
    pqr
    I have to select * fields from error table such that
    ->mkt.app_id = error.intr_id (here i am using combination of sbstr & instr to get the part before "." if present)
    ->mkt.c_mkt_id=error.mkt_id
    Where ever the above two conditions match i have to replace the mkt_id field in my select * from error table query with the
    app_mkt_id field from mkt table. If the above two condtions dont match my select * from error table should return the original mkt_id present in the error table.
    I have presently developed a query(*) which selects the app_mkt_id from mkt table where ever the two conditions match.
    How should i go about using this to get my actual requirement.
    (*)=select app_mkt_id from mkt where app_id in (select case when case_when=1 then substr(intr_id, 1, instr(intr_id,'.')-1) else substr(intr_id, 1) end from (select intr_id, case when instr(intr_id,'.',1)=0 then 0 else 1 end case_when from error)) and
    c_mkt_id in (select mkt_id from error)

    you wrote:
    (*)=select app_mkt_id from mkt where ....What is this?
    If you are writing PL/SQL the syntax is:
    SELECT ....
    INTO ....
    FROM ....
    WHERE ....This seems to be school work and thus you really need to puzzle this out for yourself.

  • Need help with changing the name.

    I got my palm pre from an uncle who lives in the states. The problem is I can't call tech support to ask them because I live in belize. The proble I have with my pre is that I have added my email account to the phone, but when I send an email, they receive it in my uncles name, my name is lanny and they receive an email form cesar, I think you can see where the problem lies. Is there anyway I can change it to my name? Please help!
    Post relates to: Pre p100eww (Sprint)

    Hello and thank you for using the Palm Help Forums!
    I would create a new Palm Profile. To do this you will need to go to the Device Info app, Reset Options, then select Full Erase. All pictures, videos, and anything else stored in the USB side of the device will be erased. I recommend that if you want to keep any of that to connect your device to a computer then click and drag everything you want to keep off of the device and onto your computer.
    After you perform the Full Erase the device is going to reboot. It is going to come up with a screen to sign in to a Palm Profile or Create a New Palm Profile. NOTE*** You will need a data connection to do this. Select Create a New Palm Profile and fill in the blanks. Once you are back into the device you can set up your email accounts again and it should display the name you created the Palm Profile with.
    I hope this helps,
    -Pat

  • Need help with a magic square program

    Hi, I have to write a code that prints out first 10 magic square numbers
    -- magic square numbers: numbers that is a perfect square and sum of consecutive integers (like 36 -- 6 squared or sum of 1 to 8)
    here's my code:
    public class Loop {
    public static void magicSquare ()
    long inc = 0;
    long integer = 0;
    long total = 0;
    for (int square =1; square>0; square++)
    total = square*square;
    int sum = 0;
    for (int i = 1; i>0; i++)
    if (sum<total){
    sum += i;
    else if (sum==total){
    System.out.println("Magic Square is: " + total);
    break;
    else {
    break;
    I have a simple seperate driver

    Merge - you have two lists, a list of squares (implicit list, you just remember the last square and what you need to increment to the next one), and a list of triangles (sums of n consecutive numbers starting at 1 are triangular numbers).
    As long as the head of one list is below the other you increment it. When the two heads coincide you have a squareTriangle.
    It ran pretty quickly on my machine, so it is probably not worth telling you how the whole thing can be reduced to pells equation and how the numbers represent successive rational approximations to the square root of 8. Continued fractions rule and are where you would go if you needed to go faster than this - but 0 seconds (which has to be a lie caused by round off error) seems good enough
      static void spewSquareTriangles(int n){
        long q = 0; // first square
        long t = 0; // first triangle
        long iq = 1;
        long it = 1;
        for(int i = 0; i<n;){
          if(q == t){
            System.out.println(i + ": " + q);
            q += iq; iq += 2; // squares increment by odd numbers 1+3 = 4;+5 = 9;+7 =16 ...
            t += it++;    // triangles increment by each number
            i++;
          } else {
            if(t < q){t += it++;} else {q += iq; iq += 2;}
        public static void main(String[] args) {
          spewSquareTriangles(10); 
    compile:
    run:
    0: 0
    1: 1
    2: 36
    3: 1225
    4: 41616
    5: 1413721
    6: 48024900
    7: 1631432881
    8: 55420693056
    9: 1882672131025
    BUILD SUCCESSFUL (total time: 0 seconds)

  • Need Help with some Resolution Basics (I think)

    Hi,
    I'm trying to use my Powerbook G4 15-in 1.5 GHz to connect to a 23-in ACD. I'm connecting to the ACD through the DVI port.
    When I do, and after mirroring the displays, only part of the ACD screen is used, the rest being dark on the outside. The display settings are already set to their maximum resolution, 1280 x 854. Can I go any higher? Is resolution the answer to the "black box" around the desktop on the ACD?
    There is an education hump with regard to the basics of resolution that I think I am not getting over.
    Thanks.

    I'm not sure what forum this question should be asked in, but this isn't it.
    That said,
    select e.*
    from equipment e -- get the list of all equipment
    inner join (select e2.equipment_number -- get the list of all equipment with too many records.
    from equipment e2
    group by e2.equipment_number
    having count(*) > 1
    ) e2_many
    on e.equipment_number = e2_many.equipment_number -- return equipment if in both lists.
    Don't have anything handy to test that with, cause I just shut down my database, so you'll get to correct any syntax boo-boos for yourself. :)

  • Need help to solve the following error

    Hi, I m using JDBC driver for sql server 2000 in the program and when i get online it will hv the following error:
    java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]Error establishing socket.
         at com.microsoft.jdbc.base.BaseExceptions.createException(Unknown Source)
         at com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source)
         at com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source)
         at com.microsoft.jdbc.sqlserver.tds.TDSConnection.<init>(Unknown Source)
         at com.microsoft.jdbc.sqlserver.SQLServerImplConnection.open(Unknown Source)
         at com.microsoft.jdbc.base.BaseConnection.getNewImplConnection(Unknown Source)
         at com.microsoft.jdbc.base.BaseConnection.open(Unknown Source)
         at com.microsoft.jdbc.base.BaseDriver.connect(Unknown Source)
         at java.sql.DriverManager.getConnection(DriverManager.java:512)
         at java.sql.DriverManager.getConnection(DriverManager.java:193)
         at Login.<init>(Login.java:26)
         at Login.main(Login.java:196)
    Exception in thread "main" Exit code: 1
    There were errors
    Can anyone help me to solve it? Thank you!

    Doesnt look like a java problem, rather a SQLServer setup problem - java can't connect.
    :1433 is the default remote access port for MS SQLServer... so you should be right there.
    1) Make sure SQLServer is set up for remote access
    2) Dunno whats going on with the server name. it looks... odd. Try specifying the IP address of the server rather than the hostname
    3) Just a final stab-in-the-dark thought.... but you mentioned it works when not connected to the internet, but not when you are connected.... could you be running a firewall (that starts when you connect to the net) that is blocking access through port 1433?

  • I need help with closing a running program. It seems like it does not count as a program. Tried to turn of the computer and closing all programs. Please help!?

    I have a problem with a grey text box. It writes and says all i do. For example: When i now write it says all the letters one for one. If i open a new rogram it says so. If i click on something it gives me information about it. I can click the box and drag it, but dont close it. I have restarted the computer and closing all windows and programs. It just popped out when i was pressing some buttons on the mac. I think it is a easy way to fix it, but i cant find out what it is named and search for it. I think it is made for help and i did not download anything to get it. If i change user on the mac it does go away when I am on the other user, but i really want to keep the one i have because off all the settings and programs i have.
    Please reply if you know anything about this.
    This is a printscreen of the box, the language is Norwegian if someone wonder...
    It is really annoying, I hope someone can help me out.

    Oh thanks alot! Really happy that people take the time to answer my `noob`questions! Would not find that out by my own.
    Thanks!

Maybe you are looking for

  • Looking for a high-res drawing app for the iPad

    I've tried a few of the available iPad drawing apps like Sketchbook Pro and Brushes. It's a little hard to tell, because documentation tends to be short on details, but it appears that most of them (with the exception of Brushes) only let you work an

  • Can I use a common music library across 2 Windows user IDs?

    My Windows XP computer is set up with 2 user accounts. iTunes is installed and all of my music is stored in my Shared Music folder (this folder is in Shared Documents, which is accessible from each user ID). I want to be able to use iTunes from eithe

  • Using the DateField in an Externally loaded SWF

    Hello, I have been having major trouble trying to get a basic PHP contact form to work within an externally loaded SWF file inside of a parent SWF. When I test the movie on its own it seems to work fine (example: I'm able to select a date from the Da

  • Material master data

    Experts! M working in MM Extraction, i 've to extarct Inventory data,before that , i need to extract material master data , like 0material_attr,text so can anyone give me the step by step procedure  to load master data pls.. Thanks Srujan

  • Why Does my mini ipad keep shutting down

    My mini iPad has IOS 7. My iPad keeps shutting off while I'm using it. How can I fix it?