The document contains code for a Java class with methods to perform basic math operations like addition, subtraction, multiplication, and division. It takes user input for two numbers, performs the operation, and outputs the result. There are also methods to count the number of times a user inputs 1 and to sum even numbers entered by the user between 1 and 20.
The document contains code for a Java class with methods to perform basic math operations like addition, subtraction, multiplication, and division. It takes user input for two numbers, performs the operation, and outputs the result. There are also methods to count the number of times a user inputs 1 and to sum even numbers entered by the user between 1 and 20.
The document contains code for a Java class with methods to perform basic math operations like addition, subtraction, multiplication, and division. It takes user input for two numbers, performs the operation, and outputs the result. There are also methods to count the number of times a user inputs 1 and to sum even numbers entered by the user between 1 and 20.
{ public static void main(String[] args) public static void { main(String[] args) TextIO.putln("This is the main()method"); { Add(); } int number,counterfor1=0; public static void Add() while(counterfor1!=5) { { TextIO.putln("Addition"); TextIO.putln("Enter your number:"); number=TextIO.getInt(); int n1=TextIO.getInt(); if(number==1) TextIO.putln("Enter your number:"); counterfor1++;} int n2=TextIO.getInt(); int sum=(n1+n2); } TextIO.putln(sum); } TextIO.put("\n"); Subtract(); } public class maucesajostine public static void Subtract() { { TextIO.putln("Subtraction"); public static void main(String[] TextIO.putln("Enter your number:"); args) int n1=TextIO.getInt(); { TextIO.putln("Enter your number:"); int n2=TextIO.getInt(); int sumeven=0,j=1,num; int different=(n1-n2); while((j<=20)&&(sumeven<=20)) TextIO.putln(different); { TextIO.put("\n"); Multiply(); num=TextIO.getInt(); } if(num%2==0) public static void Multiply() sumeven+=num; { TextIO.putln("Multiplication"); j++; TextIO.putln("Enter your number:"); } int n1=TextIO.getInt(); } TextIO.putln("Enter your number:"); int n2=TextIO.getInt(); } int product=(n1*n2); TextIO.putln(product); TextIO.put("\n"); Divide(); } public static void Divide() { TextIO.putln("Division"); TextIO.putln("Enter your number:"); int n1=TextIO.getInt(); TextIO.putln("Enter your number:"); int n2=TextIO.getInt(); int quotient=(n1/n2); TextIO.put("\n"); TextIO.putln(quotient);