Question

Create a flowgorithm program to calculate the Area of Circle first then do the Circumference of...

Create a flowgorithm program to calculate the Area of Circle first then do the Circumference of Circle. The user will have the ability to convert Area OR the Circumference. That means we need to add a decision structure to the program. Furthermore, they need to be able to do it as many times as they want. That means we need to add a main loop structure to the program. The user will also have the choice of whether to run the program or not. Once they choose to run the conversion program they can do as many conversions as they want of either conversion.

-----

This time the user will have the ability convert Area of Circle or the Circumference of Circle but as many times as they want to. You will basically have 3 loops.

Requirements:

  • Add a loop to allow the user the ability to run the conversions over and over and over
    • This means there will be a main loop that uses the answer from MainMenu()
    • There will be a loop for each conversion. That means that once they choose either Area or Circumference, they do that conversion until they choose to exit. Choosing exit will take them back to the MainMenu() loop.
  • You will need to use modules that were required in Assignment 4 as well as the additions below
  • Don’t assume anything when it comes to what the user entered, which means an error message.
  • Be sure not to include the exit menu option in the error messages
  • Module addition:
    • ProgramHeader() - ProgramHeader(5), where 5 is the assignment number, can also be a variable holding the “5”
      • Output: Assignment 5 programmed by Hugh Schuett, where “Hugh Schuett” will be replaced by your name
      • Called at the beginning of the main()
    • ConversionMenu() - The menu for which conversion to do
      • Area and Exit or Circumference and Exit
      • Exit will exit and the main will then call the MainMenu() again
      • A parameter needs to be sent into the ConversionMenu() so it know which menu to display, the Area and Exit one or the Circumference and Exit one
    • MainMenu() - The menu to choose the loop
      • Run conversions which calls ConversionMenu() or Exit program
      • Has 3 options Area, Circumference or Exit.
      • Returns the users choice to the main()
    • OutputError() - Displays the error for invalid entries
      • Needs input so you can display the appropriate error message and options
      • Used everywhere you are checking input

Homework Answers

Answer #1

Java code :

import java.util.Scanner;
class CircleDemo
{
   static Scanner sc = new Scanner(System.in);
   public static void main(String args[])
   {
      System.out.print("Enter the radius: ");
      /*We are storing the entered radius in double
       * because a user can enter radius in decimals
       */
      double radius = sc.nextDouble();
      //Area = PI*radius*radius
      double area = Math.PI * (radius * radius);
      System.out.println("The area of circle is: " + area);
      //Circumference = 2*PI*radius
      double circumference= Math.PI * 2*radius;
      System.out.println( "The circumference of the circle is:"+circumference) ;
   }
}
Know the answer?
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
Similar Questions
Write a program display the following menu: Ohms Law Calculator 1. Calculate Resistance in Ohms 2....
Write a program display the following menu: Ohms Law Calculator 1. Calculate Resistance in Ohms 2. Calculate Current in Amps 3. Calculate Voltage in volts 4. Quit Enter your choice (1-4) If the user enters 1, the program should ask for voltage in Volts and the current in Amps. Use the following formula: R= E/i Where: E= voltage in volts I= current in amps R= resistance in ohms If the user enters 2 the program should ask for the voltage...
Listing 1 shows ABCD.cpp program to compute diameter, circumference and area for a circle with r,...
Listing 1 shows ABCD.cpp program to compute diameter, circumference and area for a circle with r, radius without user-defined function. Listing 2 shows the expected output of ABCD.cpp on the screen after creating user-defined functions for 3 circles of radius. Write a complete code to compute an output of 3 circles with r, radius as shown in Listing 2. Your answer should have four (4) functions as stated below as function declaration. double displayRadius(double); double displayDiameter(double); double displayCircumference(double); double displayArea(double);
For this assignment, you will be creating a simple “Magic Number” program. When your program starts,...
For this assignment, you will be creating a simple “Magic Number” program. When your program starts, it will present a welcome screen. You will ask the user for their first name and what class they are using the program for (remember that this is a string that has spaces in it), then you will print the following message: NAME, welcome to your Magic Number program. I hope it helps you with your CSCI 1410 class! Note that "NAME" and "CSCI...
(Use C++ language) Create a program, named threeTypesLoops.cpp, that does the following; 1. Uses a For...
(Use C++ language) Create a program, named threeTypesLoops.cpp, that does the following; 1. Uses a For Loop that asks for a number between 1 and 10; Will double the number each time through the loop and display the answer. Will run five times, so the number will have been doubled five times, and the answer displayed five times. After the loop, display a message saying 'It's done!'. 2. Uses a While Loop; Ask the user to input a friend's name....
Python: Simple Banking Application Project Solution: • Input file: The program starts with reading in all...
Python: Simple Banking Application Project Solution: • Input file: The program starts with reading in all user information from a given input file. The input file contains information of a user in following order: username, first name, last name, password, account number and account balance. Information is separated with ‘|’. o username is a unique information, so no two users will have same username. Sample input file: Username eaglebank has password 123456, account number of BB12 and balance of $1000....
In C programming, Thank you Write a program to compute the area of a circle. You...
In C programming, Thank you Write a program to compute the area of a circle. You have to write a complete “C” program that compiles and runs in Codeblocks. Program requirements: 1. Declare the variables needed: radius (r) and area (yourLastName). 2. Calculate and print the area of each circle. 3. The program MUST prompt the user for a new radius (r) over and over until the user types -1. 5. Use the type double for all decimal numbers. 6....
Code a program to reproduce Madame Esmerelda’s clairvoyant test: Mme. Esmerelda conjures up a random number...
Code a program to reproduce Madame Esmerelda’s clairvoyant test: Mme. Esmerelda conjures up a random number 1-10 in her mind and commands the user to guess what it is. If the user’s guess is equal to (remember your double equal sign!) the conjured number, Mme. Esmerelda extends a job offer as a clairvoyant assistant. Add a user-driven loop that allows the user to play repeatedly if desired (but your program should conjure a new random number with every loop iteration)....
Part A. Input Validation (Name your C program yourLastName_yourFirstName_Lab4a.c) 1. Place the code you developed in...
Part A. Input Validation (Name your C program yourLastName_yourFirstName_Lab4a.c) 1. Place the code you developed in Lab 2 to obtain a diameter value from the user and compute the volume of a sphere (we assumed that to be the shape of a balloon) in a new program, and implement the following restriction on the user’s input: the user should enter a value for the diameter which is at least 8 inches but not larger than 60 inches. Using an if-else...
Java code Problem 1. Create a Point class to hold x and y values for a...
Java code Problem 1. Create a Point class to hold x and y values for a point. Create methods show(), add() and subtract() to display the Point x and y values, and add and subtract point coordinates. Tip: Keep x and y separate in the calculation. Create another class Shape, which will form the basis of a set of shapes. The Shape class will contain default functions to calculate area and circumference of the shape, and provide the coordinates (Points)...
You will write a program that loops until the user selects 0 to exit. In the...
You will write a program that loops until the user selects 0 to exit. In the loop the user interactively selects a menu choice to compress or decompress a file. There are three menu options: Option 0: allows the user to exit the program. Option 1: allows the user to compress the specified input file and store the result in an output file. Option 2: allows the user to decompress the specified input file and store the result in an...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT