Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Create a new Java project using NetBeans, giving it the name Lab4 . In Lab4Part1 do the following:Write the main method that will test the

Create a new Java project using NetBeans, giving it the name Lab4.

In Lab4Part1 do the following: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.

Enter the following code and explain in comments what is happening

public class Lab4Part2 {

/* The methods below illustrate invoking methods from other methods.

* Review the code provided, and show the order in which

* all of the methods are called.

*

* Trace the calls by hand yourself, then confirm your answer by

* running the code.

*

* Note that the method calls are preceded by the name of the class.

* In main, add at least 3 calls to the methods you created

* from part 1 using any test values you wish.

*/

public static void a(){

System.out.println("\t\ta in ");

System.out.println("\t\ta out ");

}//a

public static void b(){

System.out.println("\tb in ");

Lab4Part2.a();

System.out.println("\tb out ");

}//b

public static void c(){

System.out.println("c in ");

Lab4Part2.a();

Lab4Part2.b();

System.out.println("c out ");

}//c

public static void main(String[] args) {

System.out.println("main in ");

Lab4Part2.a();

Lab4Part2.b();

Lab4Part2.c();

System.out.println("main out ");

}//main

}//class

Add another class to your Lab4 project, and name this class Lab4Part3. In this class, create an isAscending method that accepts 3 integer numbers. The method should return true if the numbers are in ascending order. Write a main method that tests your isAscending method. Your main should display the numbers tested along with the result, such as

The numbers 20, 40, and 50 are in ascending order

The numbers 20, 14, and 9 are NOT in ascending order

In your main invoke your method 3 times, once with numbers that are ascending, once with numbers that are not ascending, and once with numbers that are the same. Copy and paste your output.

Make sure your code is readable, indented and spaced.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

Explain how cultural differences affect business communication.

Answered: 1 week ago

Question

distance between the complex num -2-3i,3+7i

Answered: 1 week ago