110k views
4 votes
A program that accepts data for an ID number of a dog's owner, and the name, breed, age, and weight of the dog. Display a bill containing all the input data as well as the weekly day care fee, which is $55 for dogs weighing less than 15 pounds, $75 for dogs from 15 to 30 pounds inclusive, $105 for dogs from 31 to 80 pounds inclusive, and $125 for dogs weighing more than 80 pounds.

User GrandFleet
by
2.8k points

2 Answers

2 votes

Final answer:

To create a program that accepts data for a dog's owner and the dog's information and displays a bill with the weekly day care fee based on the dog's weight, you can use a programming language like Python or Java.

Step-by-step explanation:

To create a program that accepts data for an ID number of a dog's owner, and the name, breed, age, and weight of the dog, you can use a programming language like Python or Java. Here's an example:





public class Dog {

private int ownerId;
private String name;
private String breed;
private int age;
private int weight;

public Dog(int ownerId, String name, String breed, int age, int weight) {
this.ownerId = ownerId;
this.name = name;
this.breed = breed;
this.age = age;
this.weight = weight;
}

public void displayBill() {
double weeklyFee;

if (weight < 15) {
weeklyFee = 55;
} else if (weight >= 15 && weight <= 30) {
weeklyFee = 75;
} else if (weight >= 31 && weight <= 80) {
weeklyFee = 105;
} else {
weeklyFee = 125;
}

System.out.println("Owner ID: " + ownerId);
System.out.println("Dog Name: " + name);
System.out.println("Breed: " + breed);
System.out.println("Age: " + age);
System.out.println("Weight: " + weight);
System.out.println("Weekly Day Care Fee: $" + weeklyFee);
}

public static void main(String[] args) {
Dog dog = new Dog(12345, "Buddy", "Golden Retriever", 3, 50);
dog.displayBill();
}
}

User Umlcat
by
3.2k points
6 votes

Answer:

JAVA program is as follows.

import java.util.Scanner;

import java.util.*;

public class Program{

public static void main(String args[]){

Scanner sc = new Scanner(System.in);

int id;

String name, breed;

int age;

double weight;

int weekly_day_care_fee_15 =55;

int weekly_day_care_fee_30 =75;

int weekly_day_care_fee_80 = 105;

int weekly_day_care_fee_greater =125;

int weekly_day_care_fee=0;

System.out.print("Enter id of dog's owner: ");

id = sc.nextInt();

System.out.print("Enter name of the dog: ");

name = sc.next();

System.out.print("Enter breed of the dog: ");

breed = sc.nextLine();

System.out.print("Enter age of the dog: ");

age = sc.nextInt();

System.out.print("Enter weight of the dog: ");

weight = sc.nextDouble();

if(weight<15)

weekly_day_care_fee = weekly_day_care_fee_15;

if(weight>=15 && weight<30)

weekly_day_care_fee = weekly_day_care_fee_30;

if(weight>=30 && weight<80)

weekly_day_care_fee = weekly_day_care_fee_80;

if(weight>=80)

weekly_day_care_fee = weekly_day_care_fee_greater;

System.out.println("");

System.out.println("====== BILL FOR WEEKLY DAY CARE OF DOGS ======");

System.out.println("");

System.out.println("ID of dog's owner \t \t \t \t \t: "+id);

System.out.println("Enter name of the dog \t \t \t \t: "+name);

System.out.println("Enter breed of the dog \t \t \t \t: "+breed);

System.out.println("Enter age of the dog \t \t \t \t: "+age);

System.out.println("Enter weight of the dog \t \t \t: "+weight);

System.out.println("The weekly day care fee of the dog : $"+weekly_day_care_fee);

}

}

OUTPUT

Enter id of dog's owner: 123

Enter name of the dog: JOHN

Enter breed of the dog: BULLDOG

Enter age of the dog: 3

Enter weight of the dog: 70

====== BILL FOR WEEKLY DAY CARE OF DOGS ======

ID of dog's owner : 123

Enter name of the dog : JOHN

Enter breed of the dog : THERAPY

Enter age of the dog : 3

Enter weight of the dog : 70.0

The weekly day care fee of the dog : $105

Step-by-step explanation:

1. All the variables are declared inside main() hence, not declared as static.

2. Variables are declared to hold owner id, name and breed of the dog, age and weight of the dog.

3. Variables are declared and initialized for all values of day care fees.

4. Multiple if statements are used to determine the fees based on the weight.

User Vijju
by
3.2k points