SHARE
TWEET

Untitled

a guest Mar 26th, 2020 77 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package homework;
  2.  
  3. import org.teachingextensions.logo.utils.EventUtils.MessageBox;
  4.  
  5. public class TedyBears02 {
  6.     public static void main(String[] args) {
  7.         TedyBears02 myApp = new TedyBears02 ();
  8.         myApp.run();
  9.     }
  10.     public void run () {
  11.         MessageBox popup = new MessageBox ();
  12.         popup.showMessage("Hello!  \nWe sell Teady Bear dolls");
  13.        
  14.         int numberInStock = 30;
  15.         int numberOrdered;
  16.        
  17.         while (numberInStock>0) {
  18.             numberOrdered = popup.askForNumericalInput("How many do you want?");
  19.             if (numberOrdered>numberInStock) {
  20.                
  21.                 popup.showMessage("We do not have that many dolls in stock\n"
  22.                         +"We have " + numberInStock+ " dolls in Stock");
  23.                        
  24.             }
  25.             else {
  26.                 numberInStock = numberInStock - numberOrdered;
  27.                 popup.showMessage("You have ordered " + numberOrdered+" dolls");
  28.             }  
  29.            
  30.         }
  31.        
  32.        
  33.         popup.showMessage("We are sold out");
  34.     }
  35. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top