answer.
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]
2 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]2 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
Which type of broadband internet access involves using cellular data networks? ​?
lesya [120]
The type of broadband internet access that involves using cellular data networks is mobile.
6 0
2 years ago
When considering server consolidation, plan on running ___________ vCPUs per core.a. 1 to 2b. 3 to 4c. 4 to 6d. 6 to 8
GREYUIT [131]

Answer:

c. 4 to 6

Explanation:

According to the VMware, a virtual machine software company widely known for producing the virtualization software, which is capable of making computer hardware components to be compartmentalized into various virtual layers, recommended the best practices of virtual CPU per core to be running 4 to 6.

Hence, in this case, the correct answer is option C

4 0
2 years ago
3.26 LAB: Leap Year A year in the modern Gregorian Calendar consists of 365 days. In reality, the earth takes longer to rotate a
Taya2010 [7]

Answer:

// program in C++ to check leap year.

// include header

#include<iostream>

using namespace std;

// main function

int main() {

// variable

  int inp_year ;

  // ask user to enter year

  cout<<"Enter year:";

  // read year

  cin>>inp_year;

  // check year is leap or not

  if (((inp_year % 4 == 0) && (inp_year % 100 != 0)) || (inp_year % 400 == 0))

  // if leap year , print leap year

     cout<<inp_year<<" is a leap year.";

  else

  // print not leap year

     cout<<inp_year<<" is not a leap year.";

  return 0;

}

Explanation:

Read year from user.Then check if year is divisible by 4 and not divisible by 100 or year is divisible by 400 then year is leap year.otherwise year is not  leap year.

Output:

Enter year:1712                                                                                                            

1712 is a leap year.

6 0
2 years ago
Read 2 more answers
Enter a formula in cell G5 that calculates the difference between the attendance totals for 2018 and 2017. Copy the formula to t
Allushta [10]
This is done by a very simple formula: the only thing you need to type is =x-y where x is the cell that contains the total of 2018 and y being the cell that contains the total for 2017. If both are numeric values you can use the formula = A1-B1 and get your result. Your <span>cells don't have to be in the same order as your formula.</span>
4 0
2 years ago
Write a program that uses the function isPalindrome given in Example 6-6 (Palindrome). Test your program on the following string
Artist 52 [7]

Answer:

#include <bits/stdc++.h>

using namespace std;

bool isPalindrome(string str)

{

   char a,b;

int length = str.length();

for (int i = 0; i < length / 2; i++)

{

   a=tolower(str[i]);//Converting both first characters to lowercase..

   b=tolower(str[length-1-i]);

   if (b != a )

return false;

}

return true;

   

}

int main() {

   string t1;

   cin>>t1;

   if(isPalindrome(t1))

   cout<<"The string is Palindrome"<<endl;

   else

   cout<<"The string is not Palindrome"<<endl;

return 0;

}

Output:-

Enter the string

madam

The string is Palindrome

Enter the string

abba

The string is Palindrome

Enter the string

22

The string is Palindrome

Enter the string

67876

The string is Palindrome

Enter the string

444244

The string is not Palindrome

Explanation:

To ignore the cases of uppercase and lower case i have converted every character to lowercase then checking each character.You can convert to uppercase also that will also work.

6 0
2 years ago
Other questions:
  • Name and summarize the four levels of administration necessary to keep human services organization operating smoothly
    9·2 answers
  • Ismael would like to insert a question mark symbol in his document. What steps will he need to follow to do that?
    5·2 answers
  • Which of the following facts determines how often a nonroot bridge or switch sends an 802.1D STP Hello BPDU message?
    14·1 answer
  • For any element in keysList with a value greater than 60, print the corresponding value in itemsList, followed by a semicolon (n
    14·2 answers
  • Wendy is an attacker who recently gained access to a vulnerable web server running Microsoft Windows. What command can she use t
    9·1 answer
  • Drag each tile to the correct box.
    12·1 answer
  • 4. When emergency changes have to be made to systems, the system software may have to be modified before changes to the requirem
    13·1 answer
  • Write code that determines the number of full days represented by the number of hours stored in the variable hours and stores th
    15·1 answer
  • Imagine a business where there are no clear boundaries defined for data and systems ownership. As a security professional, descr
    11·1 answer
  • What should businesses do in order to remain competitive under the current Cloud<br> landscape?
    6·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!