Write an algorithm to delete a node at end of the doubly linked list and create the logic for the same
Write algorithm to perform insert and delete operations in a linear queue and implement the logic for the same
Write a function that accepts an integer argument and checks if the number is
prime. Write a function that keeps count of number of times it’s been invoked
import java.util.*;
class App {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.println("Enter a String: ");
String string = in.nextLine().toLowerCase();
System.out.print("Enter character to find: ");
String characterFind = in.nextLine().toLowerCase();
int index = string.indexOf(characterFind);
System.out.print("Index Position: ");
while (index >= 0) {
System.out.print(index + " ");
index = string.indexOf(characterFind, index + 1);
}
in.close();
}
}
Do this coding without using characterFind, Array, Array functions, split
2.2
(Convert Celsius to Fahrenheit) Write a program that reads a Celsius degree in
a double value from the console, then converts it to Fahrenheit and displays the
result. The formula for the conversion is as follows:
fahrenheit = (9 / 5) * celsius + 32
Hint: In Java, 9 / 5 is 1, but 9.0 / 5 is 1.8.
Here is a sample run:
Enter a degree in Celsius: 43
43 Celsius is 109.4 Fahrenheit
(Compute the volume of a cylinder) Write a program that reads in the radius
and length of a cylinder and computes the area and volume using the following
formulas:
area = radius * radius
* TT
volume = area * length
Here is a sample run:
Enter the radius and length of a cylinder: 5.5 12 Enter
The area is 95.0331
The volume is 1140.4
given the following code what is the value of cities[3]
String cities[] = new String[5];
cities[0] = "North bay";
cities[1] = "Windsor";
cities[2] = "Kitchener";
cities[3] = "Kingston";
cities[4] = "Ottawa";
Given the following How many elements are in the array die3
int die1[] = {1,0,2,0,3,1};
int die2[] = {2,1,0,4,0,3};
int die3[] = {3,0,3,0,3,4};
int die4[] = {2,0,1,0,3,5};
int die5[] = {1,0,2,0,3,4};
int die6[] = {4,0,1,2,3,2};
int dice[][] = {die1,die2,die3,die4,die5,die6};
Create a Java program named PE2Lastname. (ex. PE2Dela_Cruz)
Construct a simple purchasing program based on the UML Class Diagram below.
The (-) symbol represents private variables, while(+) represent public.
PE2Lastname
-itemName: String
-itemPrice:double
-itemQuantity:int
-amountDue:double
+setItemName(String newItemName): void
+setTotalCost(int quantity, double price): void
+getItemName(): String
getTotalCost(): double
+readInput(): void
+writeOutput():void
Note: The readInput() method will be used to accept user input through the Scanner
class. This is done by doing the following:
a.
Importing Scanner from the java.util package.
b.
Instantiating an object of the Scanner class, Scanner s = new
Scanner(System.in);
c.
Storing the input to the variable name based on data type:
a.
For String: s.nextLine()
b.
For int: s.nextInt()
c.
For double: s.nextDouble()
d.
c) The Rectangle class contains:
• Two instance variables width (double) and length (double).
• Three constructors as shown. The no-arg constructor initializes the width and length to 1.0.
• Getter and setter for all the instance variables.
• Methods getArea() and getPerimeter().
• Override the inherited toString() method, to return "A Rectangle with width=xxx and length=zzz, which is a subclass of yyy", where yyy is the output of the toString() method from the superclass.