₦airaland Forum

Welcome, Guest: Register • Login • With Google • Trending • Recent • New

Stats: 3,344,174 members, 8,510,517 topics. Date: Friday, 30 October 2026 at 02:21 PM

Toggle theme

Someone, Please Help Debug This Code - Programming - Nairaland

Nairaland Forum › Science/Technology › Programming › Someone, Please Help Debug This Code (283 Views)

1 Reply

Someone, Please Help Debug This Code by lapo(op): 9:22pm On Mar 07, 2021
Hello all, please I can't pinpoint what I am getting wrong here. Someone help please.

public class Myclass{
public static void main(String [] args){
Inventory.trophy = new Inventory();
trophy.getlastbalance();
//Inventory.goldberg = new Inventory();


trophy.name = "trophy";
trophy.initialbalance = 20;
trophy.bought = 40;
trophy.sold = 10;
System.out.println("Stock of Trophy is "+ trophy.getlastbalance());

/*goldberg.initialbalance = 10;
goldberg.bought = 24;
goldberg.sold = 10;
System.out.println("Stock of Goldberg is "+ goldberg.getlastbalance());
*/
}
}

public class Inventory{
String name = "trophy";
int initialbalance;
int bought;
int sold;


public int getlastbalance(){
return (initialbalance + bought - sold);

//System.out.println("Stock of Trophy is "+ trophy.getlastbalance());
}


}
1 Reply

Someone, Please Help Debug This Code • Can Somebody Help Me Debug This? • Debug This Code At Your Spare Time. • 2 • 3 • 4

4 Weeks Online Programming Training • How To Build A Professional Website Within A Short Time(easy) • Closed