Question

Steps: Write a program that upon getting mass value from user, converts it to energy using...

Steps: Write a program that upon getting mass value from user, converts it to energy using Einstein’s mass-to-energy conversion equation.

You must write a function to calculate energy. Writing the whole thing in main will not get any credit.

Note: Conversion equation=> e = m x c^2

Please do these steps:

1-Draw flowchart diagram or write the pseudocode

2-Write your code

3-Run the code

4-Test for all possible inputs!

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Answer: here is the answer for your question :

--------------------------------------------------------------------------------------------------------------

Pseudocode:

declare variable m

declare variable c and intialize with 300000000

Input the mass frmo user into variable m

calculate e = m* c^2

print e

--------------------------------------------------------------------------------------------------------------

PYTHON CODE(Since any programming language is not defined, i am doing it in python. If you need in any other language, please let me know. i will help you out):


def calculate_energy(m):
c=300000000
e=m*c*c
print("BY Applying Einstein’s mass-to-energy conversion equation,Enery is : {}".format(e))
  

m=int(input("Enter mass value:"))
calculate_energy(m)#calling the calculate_energy function by passing argument

--------------------------------------------------------------------------------------------------------------

OUTPUT:

input Enter mass value:32 BY Applying Einsteins mass-to-energy conversion equation, Enery is : 2880000000000000000 ... Progr

input Enter mass value:987 BY Applying Einsteins mass-to-energy conversion equation, Enery 13 : 88830000000000000000 ... Pro

---------------------------------------------------------------------------------------------

I hope this would help you out

If you have any doubt, you can provide comment /feedback below the answer

Thanks

Add a comment
Know the answer?
Add Answer to:
Steps: Write a program that upon getting mass value from user, converts it to energy using...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a program that prompts the user to enter a 10 alphabets (A-Z) and converts it...

    Write a program that prompts the user to enter a 10 alphabets (A-Z) and converts it to numbers using the following mapping: A, B, C = 8 D, E, F = 6 G, H, I = 4 J, K, L = 5 M, N, 0 = 7 P, Q, R, S = 2 T, U, V, W = 3 X, Y, Z = 1 Please be sure to use Object Oriented Programming concepts when designing and writing code for this...

  • Write a program named FahrenheitToCelsius that accepts a temperature in Fahrenheit from a user and converts...

    Write a program named FahrenheitToCelsius that accepts a temperature in Fahrenheit from a user and converts it to Celsius by subtracting 32 from the Fahrenheit value and multiplying the result by 5/9. Display both values to one decimal place. For example, if 88.5 degrees is input, the output would be: 88.5 F is 31.4 C Answer in C# (Posting incomplete code i have so far that wont run correctly.) using System; using static System.Console; class FahrenheitToCelsius { static void Main()...

  • For this assignment, you will write a program that guesses a number chosen by your user....

    For this assignment, you will write a program that guesses a number chosen by your user. Your program will prompt the user to pick a number from 1 to 10. The program asks the user yes or no questions, and the guesses the user’s number. When the program starts up, it outputs a prompt asking the user to guess a number from 1 to 10. It then proceeds to ask a series of questions requiring a yes or no answer....

  • Write a program that receives a series of numbers from the user and allows the user...

    Write a program that receives a series of numbers from the user and allows the user to press the enter key to indicate that he or she is finished providing inputs. After the user presses the enter key, the program should print the sum of the numbers and their average.   >>> totalSum =0 >>> count=0 >>> while True:    number=input("Enter a number or press enter to quit:")    if number =="":        break    totalSum += float(number)    count+=1...

  • Write a C Program that inputs an array of integers from the user along-with the length...

    Write a C Program that inputs an array of integers from the user along-with the length of array. The program then prints out the array of integers in reverse. (You do not need to change (re-assign) the elements in the array, only print the array in reverse.) The program uses a function call with array passed as call by reference. Part of the Program has been given here. You need to complete the Program by writing the function. #include<stdio.h> void...

  • For this lab you will write a small program that prints a few "shapes" using asterisks....

    For this lab you will write a small program that prints a few "shapes" using asterisks. Your program will prompt the user to select a shape by entering a number (square or triangle for B grade, add the zig- zag for the A grade). It will then prompt for the size, and then if a square or triangle is selected it will prompt for "not filled" or "filled", and if azig-zag is selected it will prompt for the number of...

  • To write a C program (not C++) that converts numbers between Decimal and IEEE-754 format and...

    To write a C program (not C++) that converts numbers between Decimal and IEEE-754 format and vice versa. Inputs: Number in Decimal format (including special case of 0) Number in IEEE-754 format (including special cases) Output: Equivalent number in IEEE-754 format Equivalent number in Decimal Specification: The program converts a number based on choosing from a menu of choices, where each choice calls the appropriate procedure, where the choices are: Decimal to IEEE-754 conversion IEEE-754 to Decimal conversion Quit program...

  • Write an ARM program that implements a simple four-function calculator and prompts the user to enter...

    Write an ARM program that implements a simple four-function calculator and prompts the user to enter a pair of decimal integers (A and B) followed by a character that specifies one of the operators: ‘+’ for addition to compute A+B                             ‘-‘ for subtraction to compute A-B ‘*’ for multiplication to produce the product A*B ‘/’ for division to produce the quotient A/B. Input should be the pair of numbers followed by the operand followed by a return. For example...

  • Write a program in C++ that gives the temperature of earth at a depth. It must...

    Write a program in C++ that gives the temperature of earth at a depth. It must be in C++ and follow the information below: Problem description Write a program to take a depth in kilometers inside the earth as input data; calculate and display the temperature at this depth in both degrees Celsius and degree Fahrenheit. The formulas are: Celsius temperature at depth in km: celsius = 10 x depth(km) + 20 Convert celsius to fahrenheit: fahrenheit = 1.8 x...

  • Write a program which will Ask the user a series of questions using the Scanner object Based on t...

    Write a program which will Ask the user a series of questions using the Scanner object Based on the input, draw a grid of star figures on the DrawingPanel You program should ask your user: . What R, G & B values to create a color to draw the figure? How many stars across should the fgure be? How many stars tall should the figure be? Note that your program does not need to error check the users responses Your...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT