1. Create a folder named LastName_FirstName on your local drive. (ex. Reyes_Mark)
2. Using NetBeans, create a Java project named Greeting. Set the project location to your own folder.
3. Import Scanner and PriorityQueue from the java.util package.
4. Create one (1) PriorityQueue object named nicknames.
5. The output shall do the following:
5.1. Ask the user to input the nicknames of four (4) of his/her classmates.
5.2. Ask the user to press H to say “Hi” to each of them.
5.3. Display Hi and the classmate’s nickname (Ex. Hi Nika!) whenever the user presses H, and
Done saying hi when the queue gets empty.
Design a JavaFx application for “Courier Management System”.
For your better understanding, I have divided the code into the following functions and I will be explaining you function-wise:
Login
Connect
Create/ Reset
User Menu
Admin Menu
1. Write a method that swaps the value of the array in such a way that all negative
values come before the positive values in the array. The method should then
return the array.
You may use the following header for this method:
public static int[] negativeBeforePositive(int[]
array)
For example, suppose that the array has 10 values: 25, 12, 0, -7, -4, 26, -2, 18, -
9, 11
The method will return an array which would contain the values: -7, -4, -2, -9, 25,
12, 0, 26, 18, 11
Write a method called printArray() which will take an integer array as input and
prints all its elements.
You may use the following header for this method:
public static void printArray(int[] array)
NOTE: Declare and initialize the array without taking the input from user.
Treat the 0 as a value greater then negative numbers, but lesser than positive
numbers.
Print the array before and after calling the negativeBeforePositive(int[] array)
method
2. Create appropriate variables and assign values using a Scanner object.
Write a program to create a class Rectangle with the following information:
length, breadth in integer.
• Add two constructors, (a) default constructor, and (b) constructor to pass on length
and breadth of a Rectangle.
• Add a method printData( ) to print the two information about the rectangle in
console.
• Add methods printArea( ) and printPerimeter( ) to compute and print the area and
perimeter of rectangle in console.
• Create two objects of this class, r1 and r2. Show the output of both the constructors
and all method of these two objects
Write a program to create a class Rectangle with the following information:
length, breadth in integer.
• Add two constructors, (a) default constructor, and (b) constructor to pass on length
and breadth of a Rectangle.
• Add a method printData( ) to print the two information about the rectangle in
console.
• Add methods printArea( ) and printPerimeter( ) to compute and print the area and
perimeter of rectangle in console.
• Create two objects of this class, r1 and r2. Show the output of both the constructors
and all method of these two objects
amount of fuel that is left over in a vehicle after travelling a certain distance. The class should have instance variables tankCapacity to store initial size of the tank and efficiency to store initial efficiency of the vehicle. Also, set the variable fuel_ in_ tank to zero that is used to store initial fuel in tank. Include a method that returns ini_tank_size, ini_effi and fuel_in_tank. Include an method add_fuel that calculates how much fuel can be filled depending upon the fuel already in the tank and the capacity of the tank. Also, include a method drive_distance that returns how much distance can be travelled with the fuel available in the tank with the efficiency provided. Embed your class in a test program. You should decide which variables should be public, if any
The goal of this coding exam is to quickly get you off the ground with switch statement. given month as input,write a js program to find the corresponding season using switch statement
Write a program which defines a class Flight . The program calculates the fuel required by the flight for a particular distance.
Accept for flight number, destination, distance and calculate the quantity of fuel required as per following distance fuel <=1000 500
>1000 and <=2000 1100 >2000 2200
Display for flight number, destination, distance and Quantity of fuel required in tabular form
Construct a class to represent an air conditioning (AC) unit containing the following attributes
Input
The first input is an integer which will create an instance of an AC unit depending on the constructor used. This is specified below:
1 - construct an AC unit object via the default constructor (no
input needed)
2 - construct an AC unit object via the overloaded constructor
(a String for the brand followed by 1 (inverter type) or 0
(non-inverter type))
Then a number m is encountered which represents the number of operations that have to be invoked. This is then followed by an integer representing what operator to execute. The operators are specified below:
3 - calls power()
4 - calls thermostatUp()
5 - calls thermostatDown()
6 - calls temperatureUp()
7 - calls temperatureDown()
8 - calls getBrand()
9 - calls getType()
10 - calls getPower()
11 - calls getThermostat()
12 - calls getTemperature()
13 - calls display()
1
4
14
3
4
13
14Answer the following.
1. By consulting any good resource, find out what inner classes are.
2. Briefly explain how method overriding is different from method overloading.
3. Use the brief code example to illustrate the situation where an abstract class may prefer to use rather than a concrete class.
4. Explain the difference between how method parameters are passed for variables that contain object references and variables that contain primitive data types.