Question

In: Computer Science

COP 2800, Java Programming Assignment 6-1 Using Java create a program using the “Methods” we covered...

COP 2800, Java Programming

Assignment 6-1

Using Java create a program using the “Methods” we covered this week. come up with a “problem scenario” for which you can create a “solution”. Utilize any/all of the examples from the book and class that we discussed. Your program should be interactive and you should give a detailed statement about what the “description of the program – purpose and how to use it”. You should also use a “good bye” message. Remember to discuss in your “reflection” the advantage of using “methods” – we discussed “re-usability” and “modularity”. Write detail comments on the program.

You need to include all the following:

 Static Methods

 Library methods and user written methods

 Non Static Methods (Class & Object)

 Methods with arguments

 Methods without arguments

 Conditional statements

 Loops

For Example: (you could come up with any other program) - use your creativity Welcome to my “multifunction” program. In this program I have an interactive program to show the use and benefits of “methods” in Java program. You will see a “selection menu” that would allow you to use the program.

Choose 1. For your “compound interest calculator” of your “retirement nest” income, 2. For your “Interactive input of Employee attributes and then display of their attributes”, 3. For your….

Thank you for using my “multifunction” program. Have a nice day.

Solutions

Expert Solution

Save the below as Main.java

/******************************************************************************
Java program to illustrate static methods, library methods, non static methods,
methods with arguments, methods without arguments, conditional statements,
loops
*******************************************************************************/

public class Main
{
   static void staticMethod()
   {
   System.out.println("Hello World!");
   }
  
   void nonStaticMethod()
   {
   System.out.println("Test");
   }
  
   static int maxim(int a, int b)
   {
   //Conditional statement
   if(a>b)
   return a;
   else
   return b;
   }
  
   public static void main(String[] args) {
       //Calling static method without arguments
       staticMethod();
      
       //Calling library method with arguments
       int maximum = Math.max(3,4);
       System.out.println(maximum);
      
       //Calling user written method with arguments
       maximum = maxim(4,5);
       System.out.println(maximum);
      
       //Calling non static method
       //nonStaticMethod();//throws error, so have commented
      
       //Loop
       for(int i = 0; i < 3; i++)
       System.out.print("good bye! ");
   }
}


Related Solutions

Java Programming Assignment 6-1 We have covered the “Methods” this week. Apply the concepts that we...
Java Programming Assignment 6-1 We have covered the “Methods” this week. Apply the concepts that we have learnt in class and come up with a “problem scenario” for which you can create a “solution”. Utilize any/all of the examples from the book and class that we discussed. You program should be interactive and you should give a detailed statement about what the “description of the program – purpose and how to use it”. You should also use a “good bye”...
Java Programming In this assignment we are going to create our own programming language, and process...
Java Programming In this assignment we are going to create our own programming language, and process it Java. programming language has 6 commands enter add subtract multiply divide return enter, add, subtract, multiply, divide all take 1 parameter (a double value). return takes no parameters.
Program in Java using Inheritence The purpose of this assignment is to practice OOP programming covering...
Program in Java using Inheritence The purpose of this assignment is to practice OOP programming covering Inheritance. Core Level Requirements (up to 6 marks) The scenario for this assignment is to design an online shopping system for a local supermarket (e.g., Europa Foods Supermarket or Wang Long Oriental Supermarket). The assignment is mostly concentrated on the product registration system. Design and draw a UML diagram, and write the code for the following classes: The first product category is a fresh...
(Java) Create a program using 3 methods. The methods must be public and static. Ask the...
(Java) Create a program using 3 methods. The methods must be public and static. Ask the user for 3 numbers, then call the methods from main to print max, min, and average. The first method max (int x, int y, int z) returns the maximum value of 3 integer values. The second method min (int X, int y, int z) returns the minimum value of 3 integer values. And the third average (int x, int y, int z) returns the...
JAVA programming - please answer all prompts as apart of 1 java assignment. Part A Create...
JAVA programming - please answer all prompts as apart of 1 java assignment. Part A Create a java class InventoryItem which has a String description a double price an int howMany Provide a copy constructor in addition to other constructors. The copy constructor should copy description and price but not howMany, which defaults to 1 instead. In all inheriting classes, also provide copy constructors which chain to this one. Write a clone method that uses the copy constructor to create...
In this programming assignment, you are asked to write a multi-threaded program using JAVA to compute...
In this programming assignment, you are asked to write a multi-threaded program using JAVA to compute the sum of an arithmetic series from 1 to 200 using pthreads.   The main thread is responsible for creating two child threads The first child thread should compute the partial sum of the series from 1 to 100 and the second computes the partial sum of another series from 101 to 200. The main thread should accumulate the partial sums computed by the child...
CIT 149 JAVA 1 programming question. The Assignment This program will display a menu to the...
CIT 149 JAVA 1 programming question. The Assignment This program will display a menu to the user from which they can choose an option to find the area of a rectangle, the area of a triangle, or to quit. The user will make the selection and will be prompted to enter the height and width, or the base and height, depending upon which selection they made. The program will then calculate the appropriate area and display the results. This program...
Using Repl.it In this assignment you will create a Java program that allows a Bank customer...
Using Repl.it In this assignment you will create a Java program that allows a Bank customer to do the following: 1) Create a bank account by supplying a user id and password .2) Login using their id and password 3) Quit the program. Now if login was successful the user will be able to do the following: 1) Withdraw money. 2) Deposit money. 3) Request balance. 4) Quit the program. If login was not successful (for example the id or...
in java we need to order a list , if we create a program in java...
in java we need to order a list , if we create a program in java what  are the possible ways of telling your program how to move the numbers in the list to make it sorted, where each way provides the required result. list the name of sorting with short explanation
8) Create the following program using Java. Circle calculation using methods Create scanner declare double variable...
8) Create the following program using Java. Circle calculation using methods Create scanner declare double variable radius = -999 declare character choice create do while loop inside of do loop write: System.out.println(); System.out.println("*** CIRCLE CALCULATIONS ***"); System.out.println(); System.out.println("1. Enter the radius of the circle"); System.out.println("2. Display the area of the circle"); System.out.println("3. Display the circumference of the circle"); System.out.println("4. Quit"); System.out.println(); System.out.println("Enter a number from 1 - 4"); System.out.println(); Declare choice character and relate to scanner declare switch (choice) case...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT