1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
givi [52]
3 years ago
10

Assume you are given three variables, revenue, expenses, and profit, all of type Money (a structured type with two int fields, d

ollars and cents). Assign to profit the result of subtracting expenses from revenue. Let's make the happy assumption that revenue exceeds expenses. However you still may find that the cents part of expenses exceeds that of revenue. If that is the case you will have to "borrow" 1 from revenue dollars (i.e. subtract 1) and "give" it to revenue's cents (i.e. add 100!) in order to carry out the subtraction properly.
Computers and Technology
1 answer:
Andre45 [30]3 years ago
7 0

Answer:

if(revenue.cents - expenses.cents < 0){

profit.dollars = revenue.dollars - expenses.dollars - 1;

profit.cents = 1 - revenue.cents - expenses.cents;

}

else{

profit.dollars = revenue.dollars - expenses.dollars;

profit.cents = revenue.cents - expenses.cents;

}

Explanation:

We know that profit is given as: revenue - expenses from the question.

From the given expression above;

if(revenue.cents - expenses.cents < 0)

then profit.dollar will be revenue.dollars - expenses.dollars - 1; the 1 is to be carry over to the cent part. And the profit.cent will be 1 - revenue.cents - expenses.cents;

else the profit.dollars and the profit.cent is computed directly without needing to carry over:

profit.dollars = revenue.dollars - expenses.dollars;

profit.cents = revenue.cents - expenses.cents;

You might be interested in
If a person is proactive, they do NOT have to be defensive.<br> True<br> False
Thepotemich [5.8K]
The answer is true for this question
6 0
3 years ago
Read 2 more answers
By converting a given collection of tables to an equivalent third normal form collection of tables, you remove any problems aris
dolphi86 [110]

Answer:

The answer is "functional".

Explanation:

It's a relation of two attributes, usually between the primary key and other main attributes of a table. It turns the collection of tables into a third standard table array.

  • It allows you to controls the quality of data into the database.  
  • It is the disparity between the positive and weak architecture of the database plays a crucial role.

4 0
3 years ago
A(n) ______ is system software.
arsen [322]
System software<span> is a type of computer program that is designed to run a computer's hardware and application programs. If we think of the computer </span>system <span>as a layered model, the </span>system software<span> is the interface between the hardware and user applications</span>
7 0
3 years ago
Consider the following code segment in which the int variables a and b have been properly declared and initialized.
Amanda [17]

Answer:

a and b should both be declared and initialized

Explanation:

The code checks

i - if a is less than b; a should be incremented by 1

ii - if b is less than a; b should be incremented by 1

iii - if none of the two conditions were met; both a and b get incremented by 1

8 0
3 years ago
Write the following function that returns True if the list is already sorted in increasing order:
miss Akunina [59]

Answer:

# Get input and strip any leading/trailing spaces

inputList = input('Enter list: ').strip()

def issorted(lst):

   if len(lst) < 2:

       return True

   

   current = 1

   prev = 0

   while current < len(lst):

       # Compare if current value is less than the previous one

       if int(lst[current]) < int(lst[prev]):

           return False

       

       prev = current

       current += 1

   

   return True

# Convert input to list

inputList = inputList.split(' ')

# Print output

if issorted(inputList):

   print("The list is already sorted​")

else:

   print("The list is not sorted")

4 0
2 years ago
Other questions:
  • Why is knowledge of percent composition important in the mining process?
    7·1 answer
  • The inside color of text or of an object is called the:
    12·1 answer
  • A network engineer is configuring a network to be able to relay IPv6 packets. The network only supports IPv4 and does not have d
    11·1 answer
  • Why is drafting important in every industry
    6·1 answer
  • What is an objective of state-sponsored attackers?
    11·1 answer
  • Self contained sequences of actions to be performed are?
    6·1 answer
  • It's possible to __________ out of a loop if the user has entered an incorrect value that would cause an error or a problem with
    11·1 answer
  • What are the different nail disorders?
    13·1 answer
  • 1. Do you agree that Facebook is the best social media platform to use for interpersonal communication? Why or why not?
    13·2 answers
  • What can be the maximum possible length of an identifier 3163 79 can be of any length​
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!