mercredi 19 avril 2017

How can I get these if-statements to work with variables from the other methods?

import java.util.Random;
import java.util.Scanner;
public class Store
{
public in getNumGoodsSold()
{
Scanner scan = new Scanner(System.in);
int goods = scan.nextInt();
return goods;
}

public boolean isProspering()
{
Random random = new Random();
boolean goal = random.nextBoolean();
if (goal >= goods)
goal = true;
System.out.println( " Congrats your store is prospering " );
return goal;
}

public void setCost(double cost)
{
Scanner scan = new Scanner(System.in);
cost = scan.nextDouble();
}

public double sell(double tender)
{
double change;
if (tender < cost || tender != cost)
change = tender;
else
if (tender == cost)
change = 0.00;
else
if (tender > cost)
change = tender - cost;

if (tender > cost || tender == cost)
goods += 1.00;
if (goal == true)
cost += 1.00;
else
cost -= 1.00;

if (cost < 0.00)
cost = 0.00;
return change;
}
}

// So I am getting a bunch of "cannot find symbol" errors and am trying to get variables in the if-statements to work in other methods where they weren't declared, so how can I call the methods and use the variables in those methods?

Keep in mind there is no main method because there will be other classes implemented as well as a driver class.






Comments
0 Comments

0 commentaires:

Enregistrer un commentaire