Find Us On: Facebook Twitter Rss Feed Blog
Need To Register? Sign Up Login

lab 5

pinkberrygirl31
pinkberrygirl31 


Open NetBeans Select File->New->Project Make sure “Java Application” is highlighted and hit “Next” Enter “DogDemo” in Project Name and hit “Finish” In the DogDemo.java tab, enter the program on Page 267 of your textbook (leave the line that says package dogdemo; ). Select File->New File Make sure “Java Class” is highlighted and hit “Next” In the “New Java Class” window enter “Dog” in Class Name hit “Finish” Enter the program on Page 266 of your textbook (leave the line that says package dogdemo; ). Select Run->Build Project (or hit F11) (you will get error messages at the bottom if you mistyped the program) Select Run->Run Project (or hit F6) Add another instance variable to the Dog class called weight which is an int variable. Add another method to the Dog class called getSize() that returns a String. It will use the weight of the dog as follows: If the dog is less than 30 pounds, it returns the String “small”. If the dog is between 30 and 60 pounds, it returns the String “medium”. If the dog is over 60 pounds, it returns the String “large”. Add the following code to the DogDemo class: Dog otto = new Dog(); otto.name = "Otto"; otto.age = 7; otto.breed = "German Shepherd"; otto.weight = 50; System.out.println(); otto.writeOutput(); System.out.println("Otto is a " + otto.getSize() + " dog."); The output should look as follows: Name: Balto Breed: Siberian Husky Age in calendar years: 12 Age in human years: 72 Scooby is a Great Dane. He is 42 years old, or 222 in human years. Name: Otto Breed: German Shepherd Age in calendar years: 7 Age in human years: 47 Otto is a medium dog. Open a word processor (preferably Word or Wordpad) Click inside the Dog.java window to get focus. Copy the text in the window into the word processor. Click inside the DogDemo.java window to get focus. Copy the text in the window into the word processor. Execute the project again (Run->Run Project or hit F5) Click inside the Output window to get focus. Copy the text in the window into the word processor. Save the file as Lab5 and submit the file. Attachments Tags
Clarifications

Answers

Lab 5 Assigment

mariobeka
mariobeka 



I have completed all the tasks that you were asking for. Attachments
Lab5.docx (96 K) Download
Dog.java (1 K) Download Preview
<= 2) { humanYears = age * 11; } else { humanYears = 22 + ((age-2) * 5); } return humanYears; } public String getSize(){ if (weight < 30)

DogDemo.java (1 K) Download Preview
or "); int humanYears = scooby.getAgeInHumanYears(); System.out.println(humanYears + " in human years."); Dog otto = new Dog(); otto.name = "Otto"; otto.age = 7; otto.breed = "German Shepherd"; otto.weight =

Screenshots
Purchase Answer