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”...
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 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...
Answer the following in Java programming language Create a Java Program that will import a file...
Answer the following in Java programming language Create a Java Program that will import a file of contacts (contacts.txt) into a database (Just their first name and 10-digit phone number). The database should use the following class to represent each entry: public class contact {    String firstName;    String phoneNum; } Furthermore, your program should have two classes. (1) DatabaseDirectory.java:    This class should declare ArrayList as a private datafield to store objects into the database (theDatabase) with the...
4.) Create a Java program using the “extends” and “runnable” methods. You will be creating your...
4.) Create a Java program using the “extends” and “runnable” methods. You will be creating your own threaded program using the threadExtend.java code and the threadRunnable.java code. A.) Focus the threadExtend.java code DETAILS TO NOTE: - It creates 4 instances of the same thread. This means that the thread code is actually running 4 separate times - The thread accepts 2 parameters, an INTEGER from 1 to 4, as well as an ID - Note the parameters are hard coded...
PROGRAMMING LANGUAGE : JAVA Problem specification. In this assignment, you will create a simulation for a...
PROGRAMMING LANGUAGE : JAVA Problem specification. In this assignment, you will create a simulation for a CPU scheduler. The number of CPU’s and the list of processes and their info will be read from a text file. The output, of your simulator will display the execution of the processes on the different available CPU’s. The simulator should also display: -   The given info of each process -   CPU utilization - The average wait time - Turnaround time for each process...
JAVA PROGRAMMING. In this assignment, you are to create a class named Payroll. In the class,...
JAVA PROGRAMMING. In this assignment, you are to create a class named Payroll. In the class, you are to have the following data members: name: String (5 pts) id: String   (5 pts) hours: int   (5 pts) rate: double (5 pts) private members (5 pts) You are to create no-arg and parameterized constructors and the appropriate setters(accessors) and getters (mutators). (20 pts) The class definition should also handle the following exceptions: An employee name should not be empty, otherwise an exception...
Program: Java Write a Java program using good programming principles that will aggregate the values from...
Program: Java Write a Java program using good programming principles that will aggregate the values from several input files to calculate relevant percentages and write the values to an output file. You have been tasked with reading in values from multiple files that contains different pieces of information by semester. The Department of Education (DOE) would like the aggregate values of performance and demographic information by academic year. A school year begins at the fall semester and concludes at the...
Program: Java Write a Java program using good programming principles that will aggregate the values from...
Program: Java Write a Java program using good programming principles that will aggregate the values from several input files to calculate relevant percentages and write the values to an output file. You have been tasked with reading in values from multiple files that contains different pieces of information by semester.    The Department of Education (DOE) would like the aggregate values of performance and demographic information by academic year. A school year begins at the fall semester and concludes at the...
Java Programming Create a class named Problem1, and create a main method, the program does the...
Java Programming Create a class named Problem1, and create a main method, the program does the following: - Prompt the user to enter a String named str. - Prompt the user to enter a character named ch. - The program finds the index of the first occurrence of the character ch in str and print it in the format shown below. - If the character ch is found in more than one index in the String str, the program prints...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT