Java | JSP | JSF Answers

Questions: 4 418

Answers by our Experts: 3 943

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Search & Filtering

2. Search and Rescue


by CodeChum Admin



Make a program that will accept an integer and loop for the same number of times as that of the inputted integer and input random integers and add it to the array/list one by one, per line. Afterwards, make your program accept another random integer.



Using that final integer, compare from your array/list if the final integer's value is also present in your current array/list. If so, print "Present"; otherwise, print "None".





Start coding now!



Input



The first line contains the size of the array/list.


The next lines contain the integers.


The last line contains an integer to be searched.



5


3


21


2


5


23


2


Output



A line containing a string.



Present

A new taxi service based on electric vehicles is offering



services within a metro city. Following is the fare chart



including the type of taxi used to commute and price per



kilometer. Write a java program to calculate total fare



depending on the distance travelled in kilometers.



Note: Use if Control statement



Angle from the positive x axis Quadrant



Between 0 and 90 degrees I



Between 90 and 180 degrees II



Between 180 and 270 degrees III



Between 270 and 360 degrees IV



Type Fare



Micro Php15.00/Km



Macro Php35.50/Km



Shared Php8.50/Km

The quadrant in which line drawn from the origin resides



is determined by the angle that the line makes with the



positive x axis as follows:



Using this information, write a Java method that accepts the



angle of the line as user input and determines and displays



the quadrant appropriate to the input data. (Note: if the



angle is exactly 0, 90, 180, or 270 degrees the corresponding



line does not reside in any quadrant but lies on an axis).



Note: Use if Control statement

All years that are evenly divisible by 400 or are evenly



divisible by four and not evenly divisible by 100 are



leap years. For example, since 1600 is evenly divisible



by 400, the year is was a leap year. Similarly, since



1988 is evenly divisible by four but not by 100, the year



1988 was also a leap year. Using this information write



a Java method that accepts the year as user input,



determines if the year is a leap year, and displays an



appropriate message that tells the user if the entered



year is or is not a leap year.



Note: Use if Control statement


Write a java program to convert car consumption from one unit to another. Offer the user the choice of either conversion, kpl to mpg or mpg to kpl. The interface should be: PREFERRED CONVERSION: 1. kpl to mpg 2. mpg to kpl Enter your choice: 2 Enter miles per gallon value: mpg_value The equivalent kilometers per liter is: kpl_value Use the constants 1 mile = 1609 meters and 1 gallon = 3.785 liters. Useful formula: mpg = (kpl / 1.609) * 3.785 kpl = (mpg * 1.609) / 3.785 Note: the output of the program above should be formatted to 2 decimal places using the method System.out.printf(). Note: Use switch Control statement


Construct a class called Term. It is going to represent a term in polynomial expression. It has an integer coefficient and an exponent. In this case, there is only 1 independent variable that is 'x'.


There should be two operations for the Term:

  • public Term times(Term t) - multiplies the term with another term and returns the result
  • public String toString() - prints the coefficient followed by "x^" and appended by the exponent. But with the following additional rules:
  • if the coefficient is 1, then it is not printed.
  • if the exponent is 1, then it is not printed ( the caret is not printed as well)
  • if the exponent is 0, then only the coefficient is printed. 

Input

The first line contains the coefficient and the exponent of the first term. The second line contains the coefficient and the exponent of the second term.

1·1
4·3

Output

Display the resulting product for each of the test case.

4x^4

Write a java program to create menu driven calculator that performs basic arithmetic operations using switch statement . Name the class as calculator. The program should ask the user to input 2 numbers and arithmetic operator (+,/,*,-). It should perform operation according to the entered and print the entered numbers , the operator and the result.


Take your Array of InventoryItems from assignment 11 and put them in an ArrayList to show how to use lists. Print all the InventoryItems in the ArrayList for the user.

Ask the user for a ItemID, Description, and Price and make a new InventoryItem and add it to the Arraylist. Print all the InventoryItems in the ArrayList for the user to show that you added one.

Remove 2 InventoryItems from the ArrayList and print all the InventoryItems in the ArrayList for the user a last time to show that you can dynamically remove them.

Program 2

Make a 2D array to hold saleAmounts from the user for a store that has 3 departments and 4 salespeople. Put zeros in all 12 spots in the array with an initialization list or through other code.

Ask the user 3 times for a department number, salesperson number, and sale amount. Put this sale amount into the array using the department number as a row and the salesperson number as a column.

Print the 2D array for the user with row totals and column totals.


Take your Array of InventoryItems from assignment 11 and add a ItemID as an Integer and change the test data in the program to have them. (This would be like an ID in a database and would be a number like 452 or 535. It wouldn’t be anything about the data in that object. It gives us another integer value to work with.) Make sure the test data doesn’t have the 5 InventoryItem ItemIDs in order yet at the start.

Write a linear search to find an InventoryItem by Description and tell whether that InventoryItem is in the set or not.

Sort the Array by using a Bubble Sort, Select Sort, or another sort you know of (and your instructor may have shown the Insert Sort in lecture) to sort the array by ItemID. Then loop through the array printing the values of each InventoryItem to show they are now in order.

Then ask the user for a ItemID and write a Binary Search to tell whether that InventoryItem is in the set or not.



Design a java application that will store three different vehicle details for a local car dealership. The vihicle details must be stored in parallel arrays for the Vehicle identification Number (VIN), Vehicle Manufacturer and vehicle price.


Prompt the user with a menu system for searching or displaying the vehicles. The user must have the option to enter the numbers 1,2 or zero to exit the application. Make use of JOptionPanes for input and output. Create a loadArray () method that will store the vehicle details into thr three parrallel arrays.



If a user enters one provide functionality for a vehicle search. Create a searchArray () method and write code to enable the user to search for a specific vehicle. If the VIN is found in the array, display the Vehicle details.


If the VIN that the user searched for does not exist in the array, show a message to indicate that the vehicle is not found.



2 must display all vehicles

0 must exit




LATEST TUTORIALS
APPROVED BY CLIENTS