So this is going to sound like other posts but I have been racking my brain to figure this out. This code is a mod of one that my instructor posted, he said it was fine to just change the names of variables and submit it. When I did so and compiled it I received the attached error message.
Here is the code and I will italicize the line in question since line numbers are not visible. Thank You in advance!!!

import java.util.Scanner; 

public class Software
{
    public static void main ( String args [] )
    {
        String softwareName;  
        double softwareLocation;  
        double softwarePrice;  
        double softwareQuantity; 

            Scanner input = new Scanner ( System.in );

            System.out.printf("\nSoftware Name :");

            softwareName = input.nextLine();

if (!(softwareName.equals("stop")))
do {

                       Scanner input2 = new Scanner ( System.in );

                       System.out.printf("\nPlease give software price use format 999.99: ");

                softwarePrice = input.nextDouble();

            {  
             System.out.printf("\n\n**********Please use positive numbers*****\n\n");
             System.out.printf("\nPlease give software price use format 999.99: ");
             softwarePrice = input.nextDouble();
            }

            System.out.printf("\nPlease give software location use format 999.99: ");


            softwareLocation = input.nextDouble();

while (softwareLocation<0)
            { 
             System.out.printf("\n\n**********Please use positive numbers*****\n\n");
             System.out.printf("\nPlease give software location use format 999.99: ");
             softwareLocation= input.nextDouble();
            }

        softwareinfo software = new softwareinfo(softwareName, softwareLocation, softwarePrice);

        System.out.printf("\nSoftware Name:%s",software.getSoftwareName());
        System.out.printf("\nSoftware Location:%.2f",software.getSoftwareLocation());
        System.out.printf("\nSoftware Price:$%.2f",software.getSoftwarePrice());
        System.out.printf("\nSoftware Quantity:$%.2f",software.getSoftwareQuantity());

        System.out.printf("\n\nEnter Software Name or to stop :");

            softwareName = input2.nextLine();



    }while (!(softwareName.equals("stop")));
}   
}

Recommended Answers

All 3 Replies

So this is going to sound like other posts but I have been racking my brain to figure this out. This code is a mod of one that my instructor posted, he said it was fine to just change the names of variables and submit it. When I did so and compiled it I received the attached error message.
Here is the code and I will italicize the line in question since line numbers are not visible. Thank You in advance!!!

Line numbers will be visible if you use Java code tags. Read the stickies on this site. Your indentation makes it hard to read. I don't see the italics. Apparently it's this line:

softwareinfo software = new softwareinfo(softwareName, softwareLocation, softwarePrice);

Do you have a class called softwareinfo? You need one for this line. I don't know what the code was before you changed it.

import java.util.Scanner; 

public class Software
{
    public static void main ( String args [] )
    {
        String softwareName;  
        double softwareLocation;  
        double softwarePrice;  
        double softwareQuantity; 

            Scanner input = new Scanner ( System.in );

            System.out.printf("\nSoftware Name :");

            softwareName = input.nextLine();

if (!(softwareName.equals("stop")))
do {

                       Scanner input2 = new Scanner ( System.in );

                       System.out.printf("\nPlease give software price use format 999.99: ");

                softwarePrice = input.nextDouble();

            {  
             System.out.printf("\n\n**********Please use positive numbers*****\n\n");
             System.out.printf("\nPlease give software price use format 999.99: ");
             softwarePrice = input.nextDouble();
            }

            System.out.printf("\nPlease give software location use format 999.99: ");


            softwareLocation = input.nextDouble();

while (softwareLocation<0)
            { 
             System.out.printf("\n\n**********Please use positive numbers*****\n\n");
             System.out.printf("\nPlease give software location use format 999.99: ");
             softwareLocation= input.nextDouble();
            }

        softwareinfo software = new softwareinfo(softwareName, softwareLocation, softwarePrice);

        System.out.printf("\nSoftware Name:%s",software.getSoftwareName());
        System.out.printf("\nSoftware Location:%.2f",software.getSoftwareLocation());
        System.out.printf("\nSoftware Price:$%.2f",software.getSoftwarePrice());
        System.out.printf("\nSoftware Quantity:$%.2f",software.getSoftwareQuantity());

        System.out.printf("\n\nEnter Software Name or to stop :");

            softwareName = input2.nextLine();



    }while (!(softwareName.equals("stop")));
}   
}

Thank You Vernon. That is the proper line, I'm not getting a software class to develop, how can I remedy that? I know that I'm missing something because I'm rushing I have to head out of town and it is due later.

Thanks Again,
Charlie

Thank You Vernon. That is the proper line, I'm not getting a software class to develop, how can I remedy that? I know that I'm missing something because I'm rushing I have to head out of town and it is due later.

Thanks Again,
Charlie

This is the only class (Software)? If you put something named softwareinfo into your program, it needs to refer to something. What are you trying to do with that line and with the program? Changing softwareinfo to Software (your one class) won't work because the Software class has only the main function. You have lines like this:

software.getSoftwareName());

which suggests there is some class somewhere with functions and a constructor. My best guess, and it's only a guess, but I think it's a decent guess, is that the variables in lines 7 - 10 are supposed to be class variables from the Software class and are therefore supposed to be defined ABOVE main, not INSIDE main, like this:

import java.util.Scanner; 

public class Software
{
        // note these are private.  Otehrwise you wouldn't need get functions
	private String softwareName;  
	private double softwareLocation;  
	private double softwarePrice;  
	private double softwareQuantity; 


        public Software (String softwarename, double softwarelocation, double softwareprice)
        {
            // put constructor code here
        }

       // put your get functions here.  Make them public


	public static void main ( String args [] )
	{
	     String softwarename;    // note slight change in case
	     double softwarelocation;   // note slight change in case
	     double softwareprice;  // note slight change in case
	     double softwarequantity;   // note slight change in case
		
			Scanner input = new Scanner ( System.in );
			
			System.out.printf("\nSoftware Name :");
			
			softwarename = input.nextLine();
			
if (!(softwarename.equals("stop")))
do {

                       Scanner input2 = new Scanner ( System.in );
				
                       System.out.printf("\nPlease give software price use format 999.99: ");
				
				softwareprice = input.nextDouble();
				
			{  
			 System.out.printf("\n\n**********Please use positive numbers*****\n\n");
             System.out.printf("\nPlease give software price use format 999.99: ");
             softwareprice = input.nextDouble();
            }
			
			System.out.printf("\nPlease give software location use format 999.99: ");
			
			
			softwarelocation = input.nextDouble();
			
while (softwarelocation<0)
            { 
		     System.out.printf("\n\n**********Please use positive numbers*****\n\n");
             System.out.printf("\nPlease give software location use format 999.99: ");
             softwarelocation= input.nextDouble();
            }
	
		Software software = new Software (softwarename, softwarelocation, softwareprice);
		
    	System.out.printf("\nSoftware Name:%s",software.getSoftwareName());
     	System.out.printf("\nSoftware Location:%.2f",software.getSoftwareLocation());
     	System.out.printf("\nSoftware Price:$%.2f",software.getSoftwarePrice());
     	System.out.printf("\nSoftware Quantity:$%.2f",software.getSoftwareQuantity());
		
		System.out.printf("\n\nEnter Software Name or to stop :");
			
			softwarename = input2.nextLine();
			

			
	}while (!(softwarename.equals("stop")));
}	
}

Note that I changed the case of your variables in main (lines 22 - 25) so they weren't the same as your class variables (lines 6 - 9). It's not strictly necessary, but I did it to point out that some are local variables (the completely lower case variables), some are class variables (first word lower case, second upper case, and that Software is a class (all upper-case).

Write the constructor and the get functions. There may be more problems, but I'm guessing this is along the lines of what is wanted.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.