1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Romashka [77]
3 years ago
15

What is the output of the following C++ program?

Computers and Technology
1 answer:
KIM [24]3 years ago
3 0

Answer:

Output:<em> </em><em>15 11/16 inches</em>

Explanation:

#include <iostream>

using namespace std;

////////////////////////////////////////////////////////////////////////

class InchSize {

public:

   InchSize(int wholeInches = 0, int sixteenths = 0);

   void Print() const;

   InchSize operator+(InchSize rhs);

   

private:

   int inches;

   int sixteenths;

};

InchSize InchSize::operator+(InchSize rhs) {

   InchSize totalSize;

   totalSize.inches = inches + rhs.inches;

   totalSize.sixteenths = sixteenths + rhs.sixteenths;

   

   // If sixteenths is greater than an inch, carry 1 to inches.

   if (totalSize.sixteenths >= 16) {

       totalSize.inches += 1;

       totalSize.sixteenths -= 16;

   }

   return totalSize;

}

InchSize::InchSize(int wholeInches, int sixteenthsOfInch) {

   inches = wholeInches;

   sixteenths = sixteenthsOfInch;

}

void InchSize::Print() const {

   cout<<inches<<" "<<sixteenths<<"/16 inches"<<endl;

}

////////////////////////////////////////////////////////////////////////

int main() {

   InchSize size1(5, 13);

   InchSize size2(9, 14);

   InchSize sumSize;

   sumSize = size1 + size2;

   sumSize.Print();

   return 0;

}

////////////////////////////////////////////////////////////////////////

sumSize variable was printed in the end. Print() prints the calling object's inches and sixteenths variables' values.

sumSize's inches is equal to size1 plus size2's inches.

Because the sum of sixteenths was greater than 16, sumSize's sixteenth was decreased by 1 and inches was increased by 1.

You might be interested in
Integrated circuits are made up of _____ and carry an electrical current
Rasek [7]

Answer:

integrated circuits are made up of Transistor and carry an electrical current

4 0
4 years ago
Which of the following operating systems would allow a user to add functionality and sell or give away their versions?
olchik [2.2K]

Answer:open source

Explanation: what is's called

4 0
3 years ago
How can you make sure to save all annotations from a slide show?
valentinak56 [21]

Answer:

The answer is A.

Explanation:

I just did this question on Edge2021.

7 0
3 years ago
Read 2 more answers
In which situation is the person applying critical thinking skills?
Mama L [17]

I would say C is correct

7 0
3 years ago
Read 2 more answers
Print person1's kids, call the incNumKids() method, and print again, outputting text as below. End each line with a newline.
Brilliant_brown [7]

Answer:

Explanation:

The following code was written in Java and modifies the code so that for the given input such as 3 it outputs the exact information shown in the sample output.

import java.util.Scanner;

class CallPersonInfo {

   public static void main(String [] args) {

       Scanner scnr = new Scanner(System.in);

       PersonInfo person1 = new PersonInfo();

       int personsKid;

       System.out.println("How many kids do you have:");

       personsKid = scnr.nextInt();

       person1.setNumKids(personsKid);

       /* Your solution goes here */

       System.out.println("Kids: " + person1.getNumKids());

       person1.incNumKids();

       System.out.println("New Baby, kids now: " + person1.getNumKids());

   }

}

class PersonInfo {

   private int numKids;

   public void setNumKids(int setPersonsKids) {

       numKids = setPersonsKids;

   }

   public void incNumKids() {

       numKids = numKids + 1;

   }

   public int getNumKids() {

       return numKids;

   }

}

4 0
3 years ago
Other questions:
  • Critical Infrastructure and Key Resources (CIKR) are potential terrorist targets. CIKR might include: Select one: 1. All telecom
    14·1 answer
  • What does the key combination ctrl+s achieve?
    7·2 answers
  • The voluntary linkage of computer networks around the world is called the ______.
    7·1 answer
  • The text discusses three different steps when processing input. Which of the following is (are) one of those steps? (Check all t
    8·1 answer
  • Consider the following declaration.int[] beta = new int[3];int j;Which of the following input statements correctly input values
    11·1 answer
  • ________ is an encryption standard used for secure transactions such as credit card processing and online banking. TLS DMZ White
    14·1 answer
  • Define a method printFeetInchShort, with int parameters numFeet and numInches, that prints using ' and " shorthand. End with a n
    7·2 answers
  • Correct single error in this. Try to appear relaxed, but not to relaxed​
    13·1 answer
  • When both inputs of a J-K edge-triggered FF are high and the clock cycles, the output will ________.
    11·1 answer
  • 1, and
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!