Advertisement
Guest User

Untitled

a guest
Mar 3rd, 2015
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5 1.28 KB | None | 0 0
  1. /*
  2.  * To change this license header, choose License Headers in Project Properties.
  3.  * To change this template file, choose Tools | Templates
  4.  * and open the template in the editor.
  5.  */
  6. package pet.get;
  7. import java.util.*;
  8. /**
  9.  *
  10.  * @author brandon
  11.  */
  12. public class NewClass {
  13.     private String species;
  14.     private int number;
  15.     private double price;
  16.  Scanner in = new Scanner(System.in);  
  17.     public NewClass(String species, int number, double price){
  18.         this.species=species;
  19.         this.number=number;
  20.         this.price=price;
  21.     }
  22. public void change(){
  23.     if(species.equals("fish")){
  24.       System.out.print("how manys "+species+" do you need?  ");
  25.       int numc = in.nextInt();
  26.       this.number = number - numc;
  27.       this.price = price * numc;
  28.     }else{
  29.  System.out.print("how manys "+species+"s"+" do you need?  ");
  30.  int numc = in.nextInt();
  31.  this.number = number - numc;
  32.  this.price = price * numc;
  33.     }}
  34. public void print(){
  35.     if(species.equals("fish")){
  36.       System.out.println("number of "+species+" "+"available after purchase "+number+" price of purchase "+"$"+price);  
  37.     }else{
  38.  System.out.println("number of "+species+"s "+"available after purchase "+number+" price of purchase "+"$"+price);
  39.         }  
  40.     }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement