answersLogoWhite

0

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

15y ago

What else can I help you with?

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.


write a program that will display one if you enter any number without it will display zero in c?

You can use the following C program to display "1" if a user enters any non-zero number, and "0" if the entered number is zero: #include <stdio.h> int main() { int num; printf("Enter a number: "); scanf("%d", &num); if (num != 0) { printf("1\n"); } else { printf("0\n"); } return 0; } This program reads an integer from the user and checks if it is non-zero or zero, then prints the corresponding output.

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.


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

you cant


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

programming language paradigm


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 medisoft auto log off featured 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.