61.9k views
2 votes
Assume you are given two variables, salesEurope and salesAsia, each of type Money (a structured type with two int fields, dollars and cents). Write an expression whose value is true if (and only if) salesEurope is greater than salesAsia.

1 Answer

4 votes

Answer:

#include <iostream>

using namespace std;

struct Money{

int dollars;

int cents;

};

int main()

{

struct Money salesEurope,salesAsia;

cout << "Enter the Money value of dollar and cents of salesEurope: ";

cin >> salesEurope.dollars;

cin >> salesEurope.cents;

cout << "Enter the Money value of dollar and cents of salesAsia: ";

cin >> salesAsia.dollars;

cin >> salesAsia.cents;

if(salesEurope.dollars>salesAsia.dollars || salesEurope.dollars==salesAsia.dollars && salesEurope.cents>salesAsia.cents)

/*Prints out true when the above condition if (and only if) salesEurope is greater than salesAsia is true

{

cout<<"true";

}

}

Step-by-step explanation:

Using C++ for the above code, first we declare the header files in line 1 and 2. Next we use struct to create data members for type Money. Next the code prompts the user to enter the dollar and cent value of salesEurope and salesAsia. The if conditional statement in line 16 is then used to create an expression that the value is True if (and only if) salesEurope is greater than salesAsia. Line 22 prints out true when the condition is true.

User JSBach
by
4.1k points