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]
4 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]4 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
Consider an array inarr containing atleast two non-zero unique positive integers. Identify and print, outnum, the number of uniq
Delvig [45]

Answer:

Program.java  

import java.util.Scanner;  

public class Program {  

   public static boolean isPalindrome(String str){

       int start = 0, end = str.length()-1;

       while (start < end){

           if(str.charAt(start) != str.charAt(end)){

               return false;

           }

           start++;

           end--;

       }

       return true;

   }  

   public static int countPalindromePairs(String[] inarr){

       int count = 0;

       for(int i=0; i<inarr.length; i++){

           for(int j=i+1; j<inarr.length; j++){

               StringBuilder sb = new StringBuilder();

               sb.append(inarr[i]).append(inarr[j]);

               if(isPalindrome(sb.toString())){

                   count++;

               }

           }

       }

       return count == 0 ? -1 : count;

   }

   public static void main(String[] args) {

       Scanner sc = new Scanner(System.in);

       String line = sc.next();

       String[] inarr = line.split(",");

       int count = countPalindromePairs(inarr);

       System.out.println("RESULT: "+count);

   }

}

Explanation:

OUTPUT:

3 0
3 years ago
A template slide that controls the formatting of all other slides in the presentation is called a _________.
PtichkaEL [24]

Answer:

the answer is slide master

7 0
2 years ago
What is the value of creating recurring tasks?
scoundrel [369]

Answer:

✔️saves time spent manually creating multiple tasks

Explanation:

I did it on edge

4 0
3 years ago
Read 2 more answers
An arrangement in which local businesses team up with schools, hiring students to perform jobs that use knowledge and skills tau
Kazeer [188]

It is called a Cooperative program

A Cooperative program refers to a combination of both academic study and vocational activities in one curriculum of education. The purpose of this program is to provide the students with both knowledge in theory and practical skills that make them more prepared in the real world.


4 0
4 years ago
Read 2 more answers
En que parte del mall del rio venden tarjetas de google play en cuenca​
JulijaS [17]

chxgfk hcyskvuct auhchovuzq vuvscisv

6 0
3 years ago
Other questions:
  • 1. Access and PowerPoint are not included in all configurations of Microsoft Office 2013.
    14·1 answer
  • You may nest while and do-while loops, but you may not nest for loops<br><br><br><br> True False
    10·1 answer
  • Service that connects on-premises software appliances with cloud based storage is ______
    10·1 answer
  • Can someone help please
    12·1 answer
  • A friend complains that she is always running out of money even though she “never buys anything expensive.” What advice would yo
    5·2 answers
  • What is Computer categories
    9·1 answer
  • In the Unified Process (UP) methodology, most of the Implementation activities occurs during the _____ phase.
    14·1 answer
  • The metric unit used for length
    5·1 answer
  • C
    5·1 answer
  • How to print<br> 1<br> 321<br> 54321<br> 7654321<br> triangle pattern in python
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!