answersLogoWhite

0


Best Answer

In BASIC, this could be as simple as:

10 Input X

20 Input Y

30 Z=X+Y

40 Print X;" + ";Y;" = ";Z

50 END

In JAVA...

/**

* A simple calculator that adds, subtracts, multiplies, and divides.

* Written in Java by: AustinDoggie

*/

public class Calculator()

{

public Calculator()

{

// don't really have to do anything here

}

public int add(int x, int y)

{

int z = x + y; // add two numbers

return z; // and return it

}

public int subtract(int x, int y)

{

int z = x - y; // subtract two number

return z; // and return it

}

public int multiply(int x, int y)

{

int z = x*y; // multiply two number

return z; // and return it

}

public int divide(int x, int y)

{

int z = x/y; // divide two numbers

return z; // and return the result

}

}

Hope that helps.

User Avatar

Wiki User

14y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Write a program that will add the number specified by the user?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

How to write a program to accept the user name and password and then shop this is your Password?

you cant


What type of loop is used to write a program that prompts the user for a value until the user enters -1?

Any type will do, here is an example: for (leave= 0, nnum= 0; ! leave; ) { rc= scanf ("%d", &number); if (rc!=1 number==-1) { leave=1; continue; } ++nnum; ... do something with number ... }


How to write a C language program to display the times table of any number entered and then prompt the user to try again I've done till the number table but I cant prompt the user to TRY AGAIN?

The simplest way is to add a loop around the ask-for-the-number, show-the-table routine. In pseudocode:while (1) { ask-for-the-number; show-the-table; }


What type of error in an algorithm will produce unexpected results depending on the number that the user inputs?

Algorithms do not accept user input; they are not computer programs. All input to an algorithm is specified at the start of the algorithm along with any required preconditions and postconditions. If a required precondition is not specified or is specified incorrectly, then this could result in unexpected results (or undefined behaviour in programming terminology). The type of error in the algorithm is simply that the precondition was not specified.


In C Programming Language Can someone write a program that will interact with the user by name and allow for the recording of grades for three classes Tech History and Math?

More info;You will write a program that will interact with the user by name and allow for the recording of grades for three classes: Tech, History, and Math. The program will allow the user to determine how many assignments to enter in each class, the name of each assignment, the total value of each assignment, and the users score on each assignment. The program will will write the scores to a file and have the ability to:Tell the user the high and low score in each class along with the assignment nameRepeat entries back to user by assignment name and score to ensure accuracyTell the user their current grade in each classTell the user their current gpa based on the overall percentage of each class

Related questions

Write a program which takes any number of days from the user the program should display the number of years number of months formed by these days as well as the remaining days?

Write a program which takes any number of days from the user. the program should display the number of years, number of months formed by these days as well as the remaining days.


Write a program which will rise any number X to a positive power nobtain values of X and n from user?

user-generated content: disclaimer report abuse = Write a program which will rise any number X to a positive power nobtain values of X and n from user? =


Write a program to display the name of days when a user enters a number?

write a program to display your name age class schoolname e-mail 2hobby based on choice


Write a c program which displays digital watch on the screen after taking the hours and minutes from the user?

Write a program which displays digital watch on the screen, after taking the hours and minutes from the user.


What is the program that allows the user to write applications software?

programming language paradigm


How to write a program to accept the user name and password and then shop this is your Password?

you cant


Help for cit 120?

CIT 120 - Computational Thinking In QBasic, create a guessing game. You should have your program to generate a random number from 1-100 (inclusive). Let the user guess a number from 1-100. The program should let the user guess until they get the correct number. After each input, the program should tell the user whether they guessed the correct number, or if they should guess higher or guess lower. While the user is entering guesses, the program should keep a count of the number of guesses that it takes to get the correct number. After the user guesses the correct number, the program should congratulate the user and tell them how many guesses it took them to get the correct number.


Is a program with no input an incorrect program?

No, as long as it calculates something, displays something, or otherwise has an output that benefits the user, it is a program. It could be a program that makes a random number, or a program that tells the user a joke from a database.


Is created by a user for instance a report you write with a word processing program.?

data file


How do you write a c program to get a range from user and give a list of prime numbers?

To get all tutorials of "c programming" Reference:cprogramming-bd.com/c_page2.aspx# prime number


What is true regarding software on a LAN?

Software with a multi-user license may be installed on a LAN, but only the number of users specified in the EULA may have accsess to it.software with a multi-user license may be installed on a lan, but only the number of users specified in the EULA may have acces to it


How does medisoft auto log off feature protects patient data?

It logs off the user after detecting no activity for a specified number of minutes. Example: If a user steps away from his or her desk w/o first logging off, info in the Medisoft program can be viewed by anyone who uses the computer.