Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package pet.get;
- import java.util.*;
- /**
- *
- * @author brandon
- */
- public class NewClass {
- private String species;
- private int number;
- private double price;
- Scanner in = new Scanner(System.in);
- public NewClass(String species, int number, double price){
- this.species=species;
- this.number=number;
- this.price=price;
- }
- public void change(){
- if(species.equals("fish")){
- System.out.print("how manys "+species+" do you need? ");
- int numc = in.nextInt();
- this.number = number - numc;
- this.price = price * numc;
- }else{
- System.out.print("how manys "+species+"s"+" do you need? ");
- int numc = in.nextInt();
- this.number = number - numc;
- this.price = price * numc;
- }}
- public void print(){
- if(species.equals("fish")){
- System.out.println("number of "+species+" "+"available after purchase "+number+" price of purchase "+"$"+price);
- }else{
- System.out.println("number of "+species+"s "+"available after purchase "+number+" price of purchase "+"$"+price);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement