Write the main method that will test the following methods: Write the method to
ID: 3849583 • Letter: W
Question
Write the main method that will test the following methods:
Write the method to convert Celsius to Fahrenheit.
Write the method to convert Fahrenheit to Celsius
Write a method operator(a,b,c) which will receive 2 integers and one of the 5 operators (*,/,+ -, %) as a character and perform the operation and return the integer value . Example operator(2,3,’*’) will return a 6. (assume no division by zero!))
Write the overloaded method operator(a,b,c) which will receive 2 doubles and one of the 4 operators (*,/,+ -) as a character and perform the operation and return the integer value . Example operator(2.1,3,’*’) will return a 63. (assume no division by zero!))
Write the method sumOfDigits(a) which will receive and integer and return the sum of their digits. (This was a lab!!) Example sumOfDigits(941) return 15.
Explanation / Answer
class OperatorExample{
public static void main(String args[]){
int a=10;
int b=5;
System.out.println(a+b);//15
System.out.println(a-b);//5
System.out.println(a*b);//50
System.out.println(a/b);//2
System.out.println(a%b);//0
}}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.