I am attempting to run a bit of code for a school program. In this I have to create a class used to store the item number and price in order to find a discount.
I am using repl.it, an internet compiler for various languages. I have read through here and seen many posts regarding class path when running in terminal. Since everything is local to the repl.it program I am not sure what is causing these errors since I would assume all paths would be available to the programs. I have posted the code below. Thank you for any and all help.
public class Inventory
{
private String itemNumber;
private double origPrice;
public Inventory()
{
itemNumber = " ";
origPrice = 0.0;
}// end default constructor
public Inventory (String newItemNumber, double newOrigPrice)
{
itemNumber = newItemNumber;
origPrice = newOrigPrice;
}// end overloaded constructor
//Mutators
public void setItemNumber(String newItemNumber)
{
this.itemNumber = newItemNumber;
}// end setItemNumber
public void setOrigPrice(double newOrigPrice)
{
this.origPrice = newOrigPrice;
}// end setOrigPrice
//Accessors
public String getItemNumber()
{
return this.itemNumber;
}// end getItemNumber
public double getOrigPrice()
{
return this.origPrice;
}// end getOrigPrice
public void printSalesData()
{
int days = 0;
double discount = .1;
while (days <= 7)
{
origPrice = origPrice * discount;
System.out.println("The sales price after " + days + " day(s) is: " + origPrice);
}// end while
}// end printSalesData
}
For my main the code is:
import java.util.Scanner;
class UseInventory
{
public static void main (String [] args)
{
String input = " ";
Inventory inv1 = new Inventory();
Scanner user = new Scanner(System.in);
while (input.equals("y"))//fix this line
{
System.out.println("Please enter the item number: ");
inv1.setItemNumber(user.nextLine());
System.out.println("Please enter the times original price: ");
inv1.setOrigPrice(user.nextDouble());
System.out.println("Do you have any other items to enter? y or n.";
input = user.nextLine();
}//end while
}//end main
}//end class