CCC '13 J1 - Next in line Canadian Computing Competition: 2013 Stage 1, Junior #1 You know a family with three children. Their ages form an arithmetic sequence: the difference in ages between the middle child and youngest child is the same as the difference in ages between the oldest child and the middle child. For example, their ages could be 5, 10 and 15, since both adjacent pairs have a difference of 5 years. Given the ages of the youngest and middle children, what is the age of the oldest child? Input Specification The input consists of two integers, each on a separate line. The first line is the age Y of the youngest child (0

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter4: Selection Structures
Section: Chapter Questions
Problem 14PP
icon
Related questions
Question
CCC '13 J1 - Next in line
Canadian Computing Competition: 2013 Stage 1, Junior #1
You know a family with three children. Their ages form an arithmetic sequence: the difference in ages between the middle child and youngest child is the same as the difference in ages
between the oldest child and the middle child. For example, their ages could be 5, 10 and 15, since both adjacent pairs have a difference of 5 years.
Given the ages of the youngest and middle children, what is the age of the oldest child?
Input Specification
The input consists of two integers, each on a separate line. The first line is the age Y of the youngest child (0 <Y < 50). The second line is the age M of the middle child
(Y < M < 50).
Output Specification
The output will be the age of the oldest child.
Sample Input 1
Copy
12
15
Output for Sample Input 1
Copy
18
Transcribed Image Text:CCC '13 J1 - Next in line Canadian Computing Competition: 2013 Stage 1, Junior #1 You know a family with three children. Their ages form an arithmetic sequence: the difference in ages between the middle child and youngest child is the same as the difference in ages between the oldest child and the middle child. For example, their ages could be 5, 10 and 15, since both adjacent pairs have a difference of 5 years. Given the ages of the youngest and middle children, what is the age of the oldest child? Input Specification The input consists of two integers, each on a separate line. The first line is the age Y of the youngest child (0 <Y < 50). The second line is the age M of the middle child (Y < M < 50). Output Specification The output will be the age of the oldest child. Sample Input 1 Copy 12 15 Output for Sample Input 1 Copy 18
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Lower bounds sorting algorithm
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
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr