Write a program reads integer values representing hours, minutes, and seconds, a
ID: 3828884 • Letter: W
Question
Write a program reads integer values representing hours, minutes, and seconds, and prints the total number of seconds. Write a loop that will continue to input values from the user, until the user says that there are no more values. Then, output the average if one can be calculated; otherwise, print message stating no values were entered. Write the code that will determine and output the largest and the smallest number in an one-dimensional array of integers. The array length is represented by n. Write the code that will enable the user to input a phrase and will then count each vowel (separately) and spaces in a phrase inputted by the user. You must use a switch statement and a for loop. Write a program to do the following: a. declares an empty arraylist Supplies; b. adds items to the list until the user wants to stop; c. outputs the contents of the arraylist. Write a method to compute the average of an int array and return the value as a double. The int array and the number of elements in the array are both passed as parameters to the method in that order. Write a class Name that stores a person's first and last names and provides the following methods/constructor: a. Name(String first, String middle, String last)-constructor. The name should be stored in the case given; don't convert to all upper or lower case. b. get First0-returns the first name c. getLast()-returns the last name d. initials()-returns the person's initials (a 3-character string). The initials should be all in upper case, regardless of what case the name was entered in. e. toString g. Now write a program that prompts for and reads a name from the user (you'll need first and last), creates a Name object, and uses the methods of the Name class to do the following: a. prints first and last names b. prints the initialsExplanation / Answer
2.Answer:
package demo.com;
import java.util.ArrayList;
import java.util.Scanner;
public class Test {
public static void main(String[] args) {
ArrayList l=new ArrayList<>();
System.out.println(l.size());
if (l.size()!=0) {
Scanner s=new Scanner(System.in);
for (int i = 0; true; i++) {
System.out.println("enter the values");
int a=s.nextInt();
l.add(a);
System.out.println(l);
}
}else {
System.out.println("stop the user valuess");
}
}
}
5.Answer:
package demo.com;
import java.util.ArrayList;
public class Demo {
public static void main(String[] args) {
ArrayList<Integer> list = new ArrayList<Integer>();
for (int i = 0; i < 20; i++)
{
list.add(i);
}
// Do the sum
int sum = 0;
for (Integer n : list)
{
sum += n;
}
System.out.println(sum);
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.