Question

Create an application where the user inputs two double values. Pass both variables to a method named compucepercent ( that di

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

Dear Student ,

As per the requirement submitted above , kindly find the below solution.

Here a new console application in C# is created using visual studio 2017 with name "ComputerPercentApp".This application contains a class with name "Program.cs".Below is the code for this class.

Program.cs :

//namespace
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
//application namespace
namespace ComputerPercentApp
{
//class
class Program
{
//main method
static void Main(string[] args)
{
//declaring two variables
double firstNumber, secondNumber;
//asking to enter firstNumber
Console.WriteLine("Enter First Number");
//reading firstNumber
firstNumber = double.Parse(Console.ReadLine());
//asking to enter secondNumber
Console.WriteLine("Enter Second Number");
//reading secondNumber
secondNumber = double.Parse(Console.ReadLine());
//calling method and passing first number and second number
//and displaying result
Console.WriteLine(firstNumber + " is " + computePercent(firstNumber, secondNumber) + " percent of " + secondNumber);
//passing reverse order parameter
Console.WriteLine(secondNumber + " is " + computePercent(secondNumber, firstNumber) + " percent of " + firstNumber);
}
//method defination
public static int computePercent(double firstNumber, double secondNumber)
{
//retruning result
return (int)((firstNumber / secondNumber) * 100);
}
}
}

======================================================

Output : Run application using F5 and will get the screen as shown below

Screen 1 :Screen asking user to enter number

AWINDOWS system321cmd.exe Enter First Number Enter Second Number

Screen 2 :Screen showing result

AWINDOWS system321cmd.exe Enter First Number Enter Second Number is 40 percent of 5 5 is 250 percent of 2 Press any key to co

NOTE : PLEASE FEEL FREE TO PROVIDE FEEDBACK ABOUT THE SOLUTION.

Add a comment
Know the answer?
Add Answer to:
Create an application where the user inputs two double values. Pass both variables to a method...
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
  • Create the pseudo-code/flowchart for an application class named Monogram. Its main() method inputs three variables that...

    Create the pseudo-code/flowchart for an application class named Monogram. Its main() method inputs three variables that hold your first, middle, and last initials, respectively. Create a method(called Monogram()) to which you pass the three initials and that displays the initials twice—once in the order of first, middle, and last, and a second time in traditional monogram style (first, last, middle). Main inputs the data, you pass it to the Monogram Function, which will output the data

  • Java 1. Create an application named NumbersDemo whose main() method holds two integer variables. Assign values...

    Java 1. Create an application named NumbersDemo whose main() method holds two integer variables. Assign values to the variables. In turn, pass each value to methods named displayTwiceTheNumber(), displayNumberPlusFive(), and displayNumberSquared(). Create each method to perform the task its name implies. 2. Modify the NumbersDemo class to accept the values of the two integers from a user at the keyboard. This is the base code given: public class NumbersDemo { public static void main (String args[]) { // Write your...

  • Use C Create a function that will take in a vector (three double variables) representing a...

    Use C Create a function that will take in a vector (three double variables) representing a position in meters. Calculate the magnitude of the vector in meters: sqrt(x * x + y * y + z * z) Calculate the magnitude of the vector in feet: magnitudeInMeters * 3.28084 Using passing by reference, return both outputs from the same function. Input: Three unique doubles, each one representing a component of the vector. Output: Magnitude of the vector in meters, magnitude...

  • Help answer Questions in C++ 14. Create a function that swaps the values of the two...

    Help answer Questions in C++ 14. Create a function that swaps the values of the two inputs; it should do so as a pass by reference. 15. Create a function that returns the max of two numbers. 16. Create a function that rolls a dice named ROLL. It should create a random number between 1 and 6. Create another function that rolls two dice and says SNAKE EYES if you both rolls are a 1. Call these functions until you...

  • a. Create a class named Lease with fields that hold an apartment tenant's name, apartment Number,...

    a. Create a class named Lease with fields that hold an apartment tenant's name, apartment Number, monthly rent amount, and term of the lease in months. Include a constructor that initializes the name. "XXX", the apartment number to O, the rent to 1000, and the term to 12. Also include methods to get and set each of the fields. Include a nonstatic method named addPetFee() that adds $10 to the monthly rent value and calls a static method named explainPetPolicy...

  • Create an application in Visual Studios 2015 that displays the result of dividing the larger of...

    Create an application in Visual Studios 2015 that displays the result of dividing the larger of two numbers entered by the user by the smaller one. You can not label entries of one must the larger on the user interface. You must use your known logic to determine which number is larger of the two entered by the user to perform your calculations. ¢ If the smaller number is 0, the application should display the message "Cannot divide by 0"...

  • The user (me) will input between 3 and 20 data points for two variables on Sheet1...

    The user (me) will input between 3 and 20 data points for two variables on Sheet1 starting in cells A2 and B2 (your program should work if I input 3, 4, 5, … , or 20 data points). Column A will contain the values for variable x and column B will contain the values for variable y. Graphical User Interface Create a UserForm on Sheet1 that contains the following controls: A Run button will be used to execute a macro...

  • Create a program named IntegerFacts whose Main() method declares an array of 10 integers. Call a...

    Create a program named IntegerFacts whose Main() method declares an array of 10 integers. Call a method named FillArray to interactively fill the array with any number of values up to 10 or until a sentinel value (999) is entered. If an entry is not an integer, reprompt the user. Call a second method named Statistics that accepts out parameters for the highest value in the array, lowest value in the array, sum of the values in the array, and...

  • Instructions We're going to create a program which will allow the user to add values to a list, p...

    Instructions We're going to create a program which will allow the user to add values to a list, print the values, and print the sum of all the values. Part of this program will be a simple user interface. 1. In the Program class, add a static list of doubles: private statie List<double> _values new List<double>) this is the list of doubles well be working with in the program. 2. Add ReadInteger (string prompt) , and ReadDouble(string prompt) to the...

  • Create a CalculatorTest class that contains the main method. 1. Get two double numbers as input...

    Create a CalculatorTest class that contains the main method. 1. Get two double numbers as input and create an object of the ScientificCalculator Class with those two numbers. 2. Then call the 8 operations one by one sequentially and display the result. Code must be written in Java. (Sample input/output: Enter number 1: 2 Enter number 2: 3 Add() result is : 5 Sub() result is: -1 ……. Power() result is: 8 …… sqrtNum1 result is:) The Problem: Given the...

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