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
irina [24]
3 years ago
15

Assume that price is an integer variable whose value is the price (in US currency) in cents of an item. Write a statement that p

rints the value of price in the form "X dollars and Y cents" on a line by itself. So, if the value of price was 4321, your code would print "43 dollars and 21 cents". If the value was 501 it would print "5 dollars and 1 cents". If the value was 99 your code would print "0 dollars and 99 cents".
Computers and Technology
1 answer:
Natalija [7]3 years ago
5 0

Answer:

The c++ statement to show price in dollars and cents is given.

if ( price  < 100 )

   {

       y = price;

   }

   else  

   {

       x = price/100;

       y = price%100;

   }

Explanation:

The program does not take any user input as it is not specified in the question.

All the three variables used are integer variables. The variables to store dollars and cents are initialized to 0.

The integer variable price is initialized inside the program.

The value of price is decomposed in dollars and cents as per the logic shown below.

if ( price  < 100 )

   {

       y = price;

   }

   else  

   {

       x = price/100;

       y = price%100;

   }    

If value of price is below 100, the value of price is taken as cents.

If value of price is 100 or above, cents are separated by taking modulo of price, and the remaining value is taken as dollars.

This program can be tested by taking different values for the variable price.

The c++ program for the above is as follows.

#include <iostream>

using namespace std;

int main() {    

// x shows dollars and y shows cents and are initialized to 0

// price can be initialized to any value for testing

   int x = 0, y = 0, price = 1234;

   cout << " This program displays the price in dollars and cents. " << endl;    

   if ( price  < 100 )

   {

       y = price;

   }

   else  

   {

// dollar is obtained by taking numbers before decimal

// cents are obtained by taking remainder on division by 100

       x = price/100;

       y = price%100;

   }    

   cout << x << " dollars and " << y << " cents " << endl;    

   return 0;

}

OUTPUT

This program displays the price in dollars and cents.

12 dollars and 34 cents  

You might be interested in
Accessing a web site in search of magazine articles about a product before its purchase is an example of what part of the consum
GaryK [48]

Accessing a web site in search of magazine articles about a product before its purchase is an example of<u> information seeking.</u>

<u />

<h3>Why knowledge seeking is important?</h3>

Information seeking as a social phenomenon has been instrumental in identifying how academics disseminate new ideas and comment on existing research. Observing how academics make informed choices, and identify resources and strategies to stay on top of the publications is an important element of academic research.

<h3>What are information-seeking Behaviours?</h3>

Information-seeking behavior is the act of actively seeking information to answer a specific query. Information-searching behavior is the conduct which stems from the searcher interacting with the system in question.

To learn more about Information seeking, refer

brainly.com/question/1382377

#SPJ4

3 0
2 years ago
Explain LCD and give two example​
Pani-rosa [81]

Answer:

LCD means least common denominator• a "Common Denominator" is when the bottom number is the same for the fractions.

Explanation:

3 0
3 years ago
Read 2 more answers
_____ is a web application server that provides the ability to connect web servers to multiple data sources.
o-na [289]
ColdFusion/JRun is a web application server that provides the ability to connect web servers to multiple data sources.ColdFusion/JRun  is an application server developed by Adobe, that is based on Sun Microsystems' Java 2 Platform, Enterprise Edition (J2EE). The other options are eliminated because: Ms Access is <span>Database Management System , FoxPro is database development system and dBase is also data management system.</span>
7 0
4 years ago
A microcomputer that is smaller, lighter, and less powerful than a notebook, and which has a touch sensitive screen, is called a
bekas [8.4K]

I guess the answer in the blank is Tablet.

A microcomputer that is smaller, lighter, and less powerful than a notebook, and which has a touch sensitive screen, is called a tablet.

7 0
3 years ago
Write a function to calculate the distance between two points Distance( x1, y1,x2.2) For example Distance(0.0,3.0, 4.0.0.0) shou
Ivenika [448]

Answer:

The function in Python3  is as follows

def Distance(x1, y1, x2, y2):

   dist = ((x1 - x2)**2 +(y1 - y2)**2)**0.5

   return dist

   

Explanation:

This defines the function

def Distance(x1, y1, x2, y2):

This calculates distance

   dist = ((x1 - x2)**2 +(y1 - y2)**2)**0.5

This returns the calculated distance to the main method

   return dist

The results of the inputs is:

32, 32, 54, 12 \to 29.73

52,56,8,30 \to 51.11

44,94,44,39\to 55.00

19,51,91,7.5 \to 84.12

89,34,00,00 \to 95.27

4 0
3 years ago
Other questions:
  • in the breezy python gui module, what class provides the basic functionality for any window, such as the command buttons in the
    10·1 answer
  • Select the correct answer. Andy wants to become a multimedia producer. Which degree can help him achieve this goal? A. bachelor’
    5·1 answer
  • A triangle is an example of __________ .
    9·1 answer
  • A printer is displaying no images on its LED panel. What can a technician do to troubleshoot the situation? Choose two answers.
    6·1 answer
  • Daniella mailed a package to her brother three days ago. She wants to see if it has arrived yet. What technology will enable her
    10·2 answers
  • 1. We want to add a button to the tally counter in Section 9.2 that allows an operator to undo an accidental button click. Provi
    8·1 answer
  • Convert the following into binary system<br>and vice versa.<br>106​
    6·2 answers
  • Ishmael would like to capture a selected potion of his screen and then capture action he performs on that selected portion. What
    5·1 answer
  • How do I mark brainlyist
    7·2 answers
  • A(n) __________ looks and acts just like a publicly accessible website and uses the same software, hardware, and networking tech
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!