For input 6 52, the age is 6 and the weight is 52. The Dog constructor is called with the age and the weight as arguments. The Dog constructor sets the age to 6 and the weight to 52. The address of the new Dog object is assigned to myDog. The object's IncreaseAge And Weight() is called to change the object's age and weight. Finally, the object's Print() is called. Thus, the output is: Dog's age and weight are increased. Dog's age: 60 Dog's weight: 520 Not all tests passed. X 1: Compare output A Output differs. See highlights below. Special character legend Input Your output Expected output 6 52 Dog's age and weight are increased. Dog's age: 60 Dog's weight: 520 Dog's age: 60 Dog's weight: 5204 Dog's age and weight are increased. Dog's age: 60 Dog's weight: 520

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
100%

PLEASE HELP FIX CODE THAT GIVES OUT WRONG OUTPUT

(I've attached image showing the issue of output)

Here is the code I used:

#include <iostream>
using namespace std;

class Dog {
   public:
      Dog(int ageValue, int weightValue);
      void IncreaseAgeAndWeight();
      void Print();
   private:
      int age;
      int weight;
};
Dog::Dog(int ageValue, int weightValue) {
   age = ageValue;
   weight = weightValue;
}
void Dog::IncreaseAgeAndWeight() {
    age = age * 10;
    weight = weight * 10;
   cout << "Dog's age and weight are increased." << endl;
}
void Dog::Print() {
   cout << "Dog's age: " << age << endl;
   cout << "Dog's weight: " << weight <<  endl;
}


int main() {
   
  // declaring variables for age and weight
    int age;
    int weight;

    // reading age from user
    cin >> age;

    // reading weight from user
    cin >> weight;

    // creating object of class Dog
    Dog * myDog = new Dog(age, weight);

    // making function call to IncreaseAge
    myDog -> IncreaseAgeAndWeight();

    // making function call to Print
    myDog -> Print();

   myDog->Print();
   
   return 0;
}

For input 6 52, the age is 6 and the weight is 52. The Dog constructor is called with the age and the weight as arguments. The Dog
constructor sets the age to 6 and the weight to 52. The address of the new Dog object is assigned to myDog. The object's
IncreaseAgeAndWeight()
is called to change the object's age and weight. Finally, the object's Print() is called. Thus, the output is:
Dog's age and weight are increased.
Dog's age: 60
Dog's weight: 520
Not all tests passed.
X 1: Compare output ^
Output differs. See highlights below. Special character legend
Input
Your output
Expected output
6 52
Dog's age and weight are increased.
Dog's age: 60
Dog's weight: 520
Dog's age: 604
Dog's weight: 5204
Dog's age and weight are increased.
Dog's age: 60
Dog's weight: 520
Transcribed Image Text:For input 6 52, the age is 6 and the weight is 52. The Dog constructor is called with the age and the weight as arguments. The Dog constructor sets the age to 6 and the weight to 52. The address of the new Dog object is assigned to myDog. The object's IncreaseAgeAndWeight() is called to change the object's age and weight. Finally, the object's Print() is called. Thus, the output is: Dog's age and weight are increased. Dog's age: 60 Dog's weight: 520 Not all tests passed. X 1: Compare output ^ Output differs. See highlights below. Special character legend Input Your output Expected output 6 52 Dog's age and weight are increased. Dog's age: 60 Dog's weight: 520 Dog's age: 604 Dog's weight: 5204 Dog's age and weight are increased. Dog's age: 60 Dog's weight: 520
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 3 images

Blurred answer
Knowledge Booster
Reference Types in Function
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education