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
Butoxors [25]
3 years ago
9

Galleons, Sickles, and Knuts are types of coinage from the Harry Potter franchise. Write source code in C++ that converts the nu

mber of Galleons to Knuts. Your program should have a reasonable prompt for the user to enter a number of Galleons. Hint: There are 493 Knuts in a Galleon.
Computers and Technology
1 answer:
olga2289 [7]3 years ago
4 0

Answer:

The c++ program for the given scenario is given below.

#include <iostream>

using namespace std;

int main() {

   double galleons, knuts;    

   cout << " This program converts Galleons to Knuts " << endl;

   cout << " Enter the number of galleons to be converted into knuts: " << endl;

   cin >> galleons;    

   knuts = galleons * 493;    

   cout << galleons << " Galleons is equivalent to " << knuts << " Knuts. " << endl;

   return 0;

}

OUTPUT

For decimal value.

This program converts Galleons to Knuts  

Enter the number of galleons to be converted into knuts:  

1.1

1.1 Galleons is equivalent to 542.3 Knuts.  

For integer value.

This program converts Galleons to Knuts  

Enter the number of galleons to be converted into knuts:  

2

2 Galleons is equivalent to 986 Knuts.

Explanation:

This program uses two variables to holds galleons and knuts which are declared with data type double.

 double galleons, knuts;

The data type double is taken since it can hold both integer and decimal values.

The variables are not initialized since the program is supposed to take user input for the number of galleons to be converted to knuts as shown below.

The cout keyword is used to print to the standard output.

 cout << " Enter the number of galleons to be converted into knuts: " << endl;

The cin keyword is used to take the input from the user.

 cin >> galleons;

Galleons are converted into knuts using the conversion rate given in the question. The formula to convert galleons into knuts is given as follows.

  knuts = galleons * 493;

The entered number of galleons and the corresponding number of knuts are displayed to the standard output.

  cout << galleons << " Galleons is equivalent to " << knuts << " Knuts. " << endl;

In the program, endl keyword is used to insert new line.

The program terminates with the following statement since the return type of main is shown as integer.

 return 0;

You might be interested in
The current standard for RFID is based off of Group of answer choices MIT standards IEEE standards ISO standards there is no agr
mamaluj [8]

Answer:

ISO standards

Explanation:

ISO / IEC 14443 is the ISO standard that covers RFID usage by devices.

EPCglobal - Electronics Product Code Global Incorporated is also another international standard that covers RFID. These two standards work together to standardize RFID products produced by manufacturers so that these products can be the same across different markets and manufacturers. Example I can purchase a tag from one manufacturer and a transceiver from another and they would function well together. There are also other standards for RFID but the above two are the biggest and most popular with ISO being the oldest.

4 0
3 years ago
write a c++ program that reads from the user a positive integer (in a decimal representation), and prints its binary (base 2) re
Vesna [10]

Answer:

The program to this question can be described as follows:

Program:

#include <iostream> //defining header file

using namespace std;

int main() //defining main method

{

int x1,rem,i=1; //defining integer variable

long Num=0;// defining long variable

cout << "Input a decimal number: "; // print message

cin >> x1; //input value by user

while (x1!=0) //loop for calculate binary number

{

//calculating binary value    

rem= x1%2;

x1=x1/2;

Num =Num +rem*i;//holding calculate value

i=i*10;

}

cout <<Num;//print value

return 0;

}

Output:

Input a decimal number: 76

1001100

Explanation:

In the above code, four variable "x1, rem, i, and Num" is declared, in which three "x1, rem, and i" is an integer variable, and one "Num" is a long variable.

  • In the x1 variable, we take input by the user and use the while loop to calculate its binary number.
  • In the loop, first, we check x1 variable value is not equal to 0, inside we calculate it binary number that store in long "Num" variable, after calculating its binary number the print method "cout" is used to prints its value.  
5 0
3 years ago
Write a program that will ask the user to enter the amount of a purchase. The program should then compute the state and county s
iVinArrow [24]

Answer:

purchase_amount = float(input("Enter the amount of a purchase: "))

state_sales_tax = purchase_amount * 0.05

country_sales_tax = purchase_amount * 0.025

print("The amount of the purchase is " + str(purchase_amount))

print("The state sales tax is " + str(state_sales_tax))

print("The county sales tax is " + str(country_sales_tax))

print("The total sales tax is " + str(state_sales_tax + country_sales_tax))

print("The total of the sale is " + str(purchase_amount + state_sales_tax + country_sales_tax))

Explanation:

*The code is in Python.

Ask the user to enter purchase amount

Calculate the state sales tax, multiply purchase amount by 0.05

Calculate the county sales tax, multiply purchase amount by 0.025

Calculate the total sales tax, sum the state sales tax and county sales tax

Print the amount of the purchase, state sales tax, county sales tax, total sales tax and  total of the sale

7 0
3 years ago
How would I view the ruler on my document if it was not visible
svlad2 [7]
For MS Word 2010 and higher
Go to "View" and find checkbox "Ruler"
8 0
3 years ago
)Which of following can be thrown using the throwstatement?
Amanda [17]

Answer:

All of Given

Explanation:

The throw keywords can be used to throw any Throwable object. The syntax is :

throw <Throwable instance>

Note that Error and Exception are subclasses of Throwable while RuntimeException is a subclass of Exception. So the hierarchy is as follows:

Throwable

-- Error

-- Exception

   -- RuntimeException

And all of these are valid throwable entities. As a result "All of Given" is the most appropriate option for this question.

6 0
3 years ago
Read 2 more answers
Other questions:
  • Wordwrap forces you to stop typing words and press the enter key at the end of each line.
    12·1 answer
  • Select the best answer for the question. 19. While broadcasting a football game, the announcer exclaimed, "I can't believe it. C
    7·2 answers
  • The front surface of the CCD is called the _________
    11·1 answer
  • Plagiarism occurs when writers
    14·2 answers
  • Which password is an ideal and secure password?
    6·2 answers
  • How can volunteering yo help plan fundraiser for your team or club be a way to develop your strengths?
    13·1 answer
  • Remote wiping is a device security control that allows an organization to remotely erase data or email in the event of loss or t
    10·2 answers
  • Consider the following method, inCommon, which takes two Integer ArrayList parameters. The method returns true if the same integ
    15·1 answer
  • Calcula l'energia (Kwh) consumida per una màquina de 30 CV que funciona durant 2 hores.
    12·1 answer
  • what will happen to the contents of the destination ell if you copy the contents of the source cell into the destination cell
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!