Question

Visual Studio C# programming task: Every year a person has a birthday. Up until the age of 18 th...

Visual Studio C# programming task:

Every year a person has a birthday.
Up until the age of 18 their parents have decided to give them the number of presents that is equal to 20 minus their age.
Part 1. Create a program that asks for their age (idiot proof, must be a number that is between 1 and 18). It then calculates how many presents they should get
Part 2. Improve this program to tell them how many presents they have received in their lifetime.

Specification:

You must use modules to decompose your problem into smaller more manageable parts.
You must use well-named variables and constants.

0 0
Add a comment Improve this question Transcribed image text
Answer #1


#include <stdio.h>

int main()
{
    int total,age,i;
    printf("enter the age");
    scanf("%d",&age);
    total=20;
    for(i=1;i<=age;i++)
    {
        total=total+(20-i);
    }
    printf("\ntotal number of presents are %d",total);
    total=20;
    for(i=1;i<=18;i++)
    {
        total=total+(20-i);
    }
    printf("\ntotal number of presents received in the lifetime are %d",total);
    return 0;
}


op:

nput enter the age3 total number of presents are 74 total number of presents received in the lifetime are 209

Add a comment
Know the answer?
Add Answer to:
Visual Studio C# programming task: Every year a person has a birthday. Up until the age of 18 th...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • If you’re using Visual Studio Community 2015, as requested, the instructions below should be exact but...

    If you’re using Visual Studio Community 2015, as requested, the instructions below should be exact but minor discrepancies may require you to adjust. If you are attempting this assignment using another version of Visual Studio, you can expect differences in the look, feel, and/or step-by-step instructions below and you’ll have to determine the equivalent actions or operations for your version on your own. INTRODUCTION: In this assignment, you will develop some of the logic for, and then work with, the...

  • Code is in C# Your instructor would like to thank to Marty Stepp and Hélène Martin...

    Code is in C# Your instructor would like to thank to Marty Stepp and Hélène Martin at the University of Washington, Seattle, who originally wrote this assignment (for their CSE 142, in Java) This program focuses on classes and objects. Turn in two files named Birthday.cs and Date.cs. You will also need the support file Date.dll; it is contained in the starter project for this assignment. The assignment has two parts: a client program that uses Date objects, and a...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT