Question

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

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:

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...
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
  • 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...

  • use visual studio, this is the step how to creat the project. creat new project in...

    use visual studio, this is the step how to creat the project. creat new project in the next page make sure to select visual C++ then empty project on the next dialog box. after you create new project click on add new item and then select C++ source file (cpp file) and click add. after you finish, make sure you send me the run file ( result) as well Write a program that calculates and prints the amount of wages...

  • THIS IS FOR C++ PROGRAMMING USING VISUAL STUDIO THE PROGRAM NEEDS TO BE IN C++ PROGRAMMING #inclu...

    THIS IS FOR C++ PROGRAMMING USING VISUAL STUDIO THE PROGRAM NEEDS TO BE IN C++ PROGRAMMING #include "pch.h" #include #include using namespace std; // Function prototype void displayMessage(void); void totalFees(void); double calculateFees(int); double calculateFees(int bags) {    return bags * 30.0; } void displayMessage(void) {    cout << "This program calculates the total amount of checked bag fees." << endl; } void totalFees() {    double bags = 0;    cout << "Enter the amount of checked bags you have." << endl;    cout <<...

  • Programming question. Using Visual Studio 2019 C# Windows Form Application (.NET Framework) Please include code for...

    Programming question. Using Visual Studio 2019 C# Windows Form Application (.NET Framework) Please include code for program with ALL conditions met. Conditions to be met: Word Problem A person inherits a large amount of money. The person wants to invest it. He also has to withdraw it annually. How many years will it take him/her to spend all of the investment that earns at a 7% annual interest rate? Note that he/she needs to withdraw $40,000.00 a year. Also there...

  • Fix program errors and improve code Visual Studio C# Console App (.NET Framework) Task The program...

    Fix program errors and improve code Visual Studio C# Console App (.NET Framework) Task The program must allow for the teacher to either enter a predetermined number of scores (e.g. 10 exam scores), to keep allowing them to enter in scores until they are finished. You will need to convert these scores to a percentage then store these in a list. You will perform some calculations on these results and also display the contents of the list (percentage values) back...

  • 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...

  • This C++ Programs should be written in Visual studio 2017 PROGRAM 1: Comparing Using Arrays to...

    This C++ Programs should be written in Visual studio 2017 PROGRAM 1: Comparing Using Arrays to Using Individual Variables One of the main advantages of using arrays instead of individual variables to store values is that the program code becomes much smaller. Write two versions of a program, one using arrays to hold the input values, and one using individual variables to hold the input values. The programs should ask the user to enter 10 integer values, and then it...

  • About Classes and OOP in C++ Part 1 Task 1: Create a class called Person, which...

    About Classes and OOP in C++ Part 1 Task 1: Create a class called Person, which has private data members for name, age, gender, and height. You MUST use this pointer when any of the member functions are using the member variables. Implement a constructor that initializes the strings with an empty string, characters with a null character and the numbers with zero. Create getters and setters for each member variable. Ensure that you identify correctly which member functions should...

  • This a lab for C++ using visual studio 2017 Lab 10 Total 50 points Stacks and...

    This a lab for C++ using visual studio 2017 Lab 10 Total 50 points Stacks and Queues - Part A (40 points) Finish the code for Lab10aStacksAndQueues.cpp . You will write code for the same function which will return true if the values of the elements of the vector that is passed to it are the same read both forwards and backwards. If they are not the same in both directions, it will return false. Don’t change anything in the...

  • This is a standard C++ programming assignment using a command line g++ compiler or the embedded...

    This is a standard C++ programming assignment using a command line g++ compiler or the embedded one in zyBooks. No GUI forms and no Visual Studio. No external files and no databases are used. There is only one object-oriented program to complete in this assignment. All code should be saved in a file named ExamScoresUpdate.cpp, which is the only file to submit for grading. No .h files used. The .cpp file contains main() and two classes, ExamScores and DataCollector. There...

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