Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Lab Assignment #6 The following is an example of a non-static void method that uses no parameters. call a void method named display Profit to

image text in transcribed
Lab Assignment #6 The following is an example of a non-static void method that uses no parameters. call a void method named display Profit to display/print the profit that will be calculated from that amount entered. Name the class ModularProfitAmt. *This program demonstrates declaring and calling a void method that uses no parameters Hint: Use the value 0.23 to represent 23 percent. public class MethodExample ( Complete Java modular program, enter it and run it from JDoodle.com, save, download, and submit it in Blackboard. public static void main(String args) { MethodExample meObj = new MethodExample(); //create MethodExample object What is the method header? Does the method need parameters, if so, how many? System.out.printin("before call"); meObj.methodName(): // call to methodName() System.out.printin("after call"); 3. Write/design a Java program that prompts the user to enter the length and width of a rectangle and //method definition for non-static void method with no parameters calculates the area of the rectangle and then call a method named display Area( ) to display/output the area public void methodName() { with description. Name the class ComputeArea. System.out.printin("Hello from method"); HINT: use area = length * width What is the method header? Does the method need parameters, if so, how many? 1. Design a Java modular program that calls a void method named displayAddress to display/print the following information on separate lines: Name the class ModularAddress. Your name Your address, with city, state, and ZIP Your telephone number . Your college major What is the method header? Does the method need parameters, if so, how many? The following is an example of a non-static void method that uses parameters. * Description: This modular program declares and calls a void method with parameters import java.util.Scanner; public class MethodExample2 { public static void main(String args) { Scanner input = new Scanner (System.in); /declare Scanner object MethodExample2 me2Object = new MethodExample2(); //declare MethodExample2 object System.out.print("Enter an integer: "); //prompt the user int num1 = input.nextInt(); //call Scanner method nextInt() int sum = num1 + 2 * num1; me2Object.displaySum(numl, sum); / 2 arguments System.out. printin("All done"); //close main() method /displaySum void method definition public void displaySum(int nl, int sum) ( System.out.printin("The Sum of " + num] + "and twice its value is"" + sum); } //close displaySum() method //close class 2. A company has determined that its annual profit is typically 23 percent of total sales. Using the above example, design/write a Java modular program that asks/prompts the user to enter the projected amount of total sales, and then

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

Mobile Communications

Authors: Jochen Schiller

2nd edition

978-0321123817, 321123816, 978-8131724262

More Books

Students also viewed these Programming questions