Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Java eclipse Objective: Begin studying for your midterm by completing a full sca

ID: 3590307 • Letter: J

Question

Java eclipse

Objective: Begin studying for your midterm by completing a full scale lab

What to do:

You are still working for the vet’s office, but you are now working in the scheduling department.

Write a program that takes input from the user via a scanner and asks them these questions

Do you have a dog or a cat? (the user MUST enter DOG or CAT in all caps, if not, an error displays and the user is prompted again)

From here, a Dog object is created or a Cat object is created. The messages below change and can display “Dog” or “Cat” depending on what is selected. The code below shows the information for “Dog” (Notice that it says dog in the prompts)

What is your dog’s name?

How old is your dog?

Is your dog up to date on his shots?

Do you want to make appointments for next year? (the user MUST enter YES or NO in all caps, if not, an error pops up and the user is prompted again)If YES, prompt how many appointments and display a message that their appointment is scheduled (shown in the sample output)

Example: 6 appointments will schedule their appointments on 1/1/2018, 2/1/2018, 3/1/2018, 4/1/2018, 5/1/2018, 6/1/2018 (this must be a loop)

(You also need to check to make sure they don’t answer >12)

If NO, then display a message saying “make sure you call us to schedule an appointment after 1/1/2018!”

At the end display “Goodbye and thank you!”

terminated> VetAppointment [Java Application] CProgram FilesJavaire1.8.0 1011binjavaw.exe (Oct 4, 2017, 11:35:11 AM) Do you have a DOG or a CAT? Dog Please enter your response using all CAPS Do you have a DOG or a CAT? >> DOG What is your dog's name? >> Fido Do you have a DOG or a CAT? >> Dog What is your dog's name? >> Fido How old is your dog? 17 Is your dog up to date on his shots? >> Yes Do you want to make appointments for next year? >> Yes Please enter your response using all CAPS Do you want to make appointments for next year? >> YES How many appointments do you want to schedule? >> 16 Please enter a number between 1 and 12 How many appointments do you want to schedule? >> 2 Fido, who is 17 and is up to date on his shots has appointments on: 1/1/2018 2/1/2018 Goodbye and thank you!

Explanation / Answer

import java.util.Scanner;

/*
* Java eclipse

Objective: Begin studying for your midterm by completing a full scale lab
What to do:
You are still working for the vet’s office, but you are now working in the scheduling department.
Write a program that takes input from the user via a scanner and asks them these questions
Do you have a dog or a cat? (the user MUST enter DOG or CAT in all caps, if not, an error displays and the user is prompted again)
From here, a Dog object is created or a Cat object is created. The messages below change and can display “Dog” or “Cat” depending on what is selected. The code below shows the information for “Dog” (Notice that it says dog in the prompts)
What is your dog’s name?
How old is your dog?
Is your dog up to date on his shots?
Do you want to make appointments for next year? (the user MUST enter YES or NO in all caps, if not, an error pops up and the user is prompted again)If YES, prompt how many appointments and display a message that their appointment is scheduled (shown in the sample output)
Example: 6 appointments will schedule their appointments on 1/1/2018, 2/1/2018, 3/1/2018, 4/1/2018, 5/1/2018, 6/1/2018 (this must be a loop)
(You also need to check to make sure they don’t answer >12)
If NO, then display a message saying “make sure you call us to schedule an appointment after 1/1/2018!”
At the end display “Goodbye and thank you!”
*/

public class VetClinicSchedule {
  
public static boolean isUpper(String str)
{
for (int i=0; i < str.length(); i++)
{
if (Character.isLowerCase(str.charAt(i)))
{
return false;
}
}
return true;
}
  
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
  
String animal;
while(true) {
System.out.print("Do you have a DOG or a CAT? >> ");
animal = sc.nextLine();
if (!isUpper(animal)) {
System.out.println("Please enter your response using all CAPS");
}
else if (!animal.equals("DOG") && !animal.equals("CAT")) {
System.out.println("Please enter either of DOG or CAT in all caps");
}
else {
break;
}
}
  
String name;
System.out.print("What is your " + animal.toLowerCase() + "'s name? >> ");
name = sc.nextLine();
  
int age;
System.out.print("How old is your " + animal.toLowerCase() + "? >> ");
age = Integer.parseInt(sc.nextLine());
  
boolean isUptoDateOnShots = false;;
System.out.print("Is your dog up to date on his shots? >> ");
if (sc.nextLine().equals("Yes")) {
isUptoDateOnShots = true;
}
  
boolean shouldSchedule = false;
while(true) {
System.out.print("Do you wanyt to make appointments for next year? >> ");
String response = sc.nextLine();
if (!isUpper(response)) {
System.out.println("Please enter your response using all CAPS");
}
else if (!response.equals("YES") && !response.equals("NO")) {
System.out.println("Please enter either of YES or NO in all caps");
}
else {
if (response.equals("YES")) shouldSchedule = true;
  
break;
}
}
if (! shouldSchedule) {
System.out.println("make sure you call us to schedule an appointment after 1/1/2018!");
}
else {
int appointments;
while(true) {
System.out.print("How many appointments do you want to shedule? >> ");
appointments = Integer.parseInt(sc.nextLine());
if (appointments > 12) {
System.out.println("Please neter a number between 1 and 12");
} else {
break;
}
}
String s = "is up to date on his shots";
if (! isUptoDateOnShots) {
s = "is not up to date on his shots";
}
System.out.println(animal + " , who is " + age + " and " + s +" has appointments on:");
for(int i = 1; i <= appointments; i++) {
System.out.println(i + "/1/2018");
}
}
System.out.println("Goodbye and thank you!");
}

}

Sample run

Do you have a DOG or a CAT? >> Dog
Please enter your response using all CAPS
Do you have a DOG or a CAT? >> DOG
What is your dog's name? >> Fido
How old is your dog? >> 17
Is your dog up to date on his shots? >> Yes
Do you wanyt to make appointments for next year? >> Yes
Please enter your response using all CAPS
Do you wanyt to make appointments for next year? >> YES
How many appointments do you want to shedule? >> 16
Please neter a number between 1 and 12
How many appointments do you want to shedule? >> 2
DOG , who is 17 and is up to date on his shots has appointments on:
1/1/2018
2/1/2018
Goodbye and thank you!

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote