Ask Question
7 January, 08:38

Assume you have a variable sales of type Money where the latter is a structured type with two int fields, dollars and cents. Write a statement that reads two integers from standard input, a dollar amount followed by a cents amount, and store these values in the appropriate fields in sales.

struct Money

{

int dollars, cents;

};

int x, y;

cin>>x>>y;

sales. dollars = x;

sales. cents = y;

+5
Answers (2)
  1. 7 January, 09:06
    0
    The answer to the question is included in your question. I guess you need an explanation or clarification.

    See Explanation Below

    Explanation:

    struct Money

    {

    int dollars, cents;

    };

    int x, y;

    cin>>x>>y;

    sales. dollars = x;

    sales. cents = y;

    The code segment is written in C+ + programming language

    On Line 1 of the code segment;

    The struct keyword is used in c+ + and other c type programming to define structure. The name of the structure is Money.

    It defines a data type such that the data type is a collection of system and user defined data types

    The Money structure defines two integer variables; dollars and cents on line 3.

    On line 6, two integer variables x and y are declared.

    On line 7, the two variables received inputs from the user.

    On line 8, the value of variable x is assigned to dollar

    On line 9, the value of variable x is assigned to cent
  2. 7 January, 09:49
    0
    int x, y;

    cin>>x>>y;

    sales. dollars = x;

    sales. cents = y;

    Explanation:

    The answer is already part of the question.

    First, integer x and y is declared. Then, x and y is received via the standard input. Then x is assigned to sales. dollars while y is assigned to sales. cents.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “Assume you have a variable sales of type Money where the latter is a structured type with two int fields, dollars and cents. Write a ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers