You have not mentioned the programming language. The question
seemed to be Java
Given below is the Java code for the question. Please do rate the
answer if it helped. Thank you.
import java.util.Scanner;
public class Lab2a {
public static void secondTime(int inputSeconds)
{
int hours, mins, secs;
mins = inputSeconds / 60;
secs = inputSeconds % 60;
hours = mins / 60;
mins = mins % 60;
System.out.println(inputSeconds + "
corresponds to: ");
System.out.println(hours + " hours,
" + mins + " minutes and " + secs + " seconds");
}
public static int inSeconds(int hours, int mins, int
secs)
{
int total = hours * 60 * 60 + mins
* 60 + secs;
System.out.println(hours + " hours
" + mins + " minutes and " + secs + " seconds corresponds
to:");
System.out.println(total + "
seconds");
return total;
}
public static void main(String[] args) {
//test inSeconds()
inSeconds(3, 15, 12);
inSeconds(0, 0, 0);
inSeconds(12, 30, 5);
inSeconds(15, 45, 6);
System.out.println("8:45:20
corresponds to " + inSeconds(8, 45, 20) );
System.out.println();
Scanner input = new
Scanner(System.in);
int inputSeconds;
System.out.println("Enter total no.
of seconds: ");
inputSeconds =
input.nextInt();
secondTime(inputSeconds);
}
}
output
====
3 hours 15 minutes and 12 seconds corresponds to:
11712 seconds
0 hours 0 minutes and 0 seconds corresponds to:
0 seconds
12 hours 30 minutes and 5 seconds corresponds to:
45005 seconds
15 hours 45 minutes and 6 seconds corresponds to:
56706 seconds
8 hours 45 minutes and 20 seconds corresponds to:
31520 seconds
8:45:20 corresponds to 31520
Enter total no. of seconds:
5000
5000 corresponds to:
1 hours, 23 minutes and 20 seconds
Part 3 (Lab2a) In this exercise you will: a. Write a method called secondTime that takes...
CSSSKL 142 Lab 3 (Part 2) In this exercise you will write a method that takes a "Scanner" object from main and uses it to ask the user to input tow integers using the keyboard, sums their square roots, and prints a statement based on what bucket the result is in. The possible buckets are "Less than 10", "Between 10 and 20", "Between 20 and 30", and "Great than 30." Negative integers should be rejected with the appropriate message printed...
This Java program reads an integer from a keyboard and prints it out with other comments. Modify the comments at the top of the program to reflect your personal information. Submit Assignment1.java for Assignment #1 using Gradescope->Assignemnt1 on canvas.asu.edu site. You will see that the program has a problem with our submission. Your program is tested with 4 testcases (4 sets of input and output files). In order to pass all test cases, your program needs to produce the same...
part one : Review Exercises 1. Write method called raggedCount that takes an integer n as argument and returns a ragged array of n rows of lengths 1, 2, 3, 4, ... , n and the whole array has the integers 1, 2, 3, 4, ... , n(n+1) 2 in row order. For example, raggedCount(4) should return the array: 1 2 3 4 5 6 7 8 9 10 1 2. Write a method called arrayConcat that takes as argument...
Write a static method called encodeString that takes a string as input and prints to the console a word where each letter is advanced by one value. In addition, your method should return the encoded String. You may make use of the method provided below to help you. public static char encode(char x) { int current = x; current++; return (char)current; } This method takes a character and returns an "encoded" character. In other words, encode('a') will return 'b'. Your...
package week_3; /** Write a method called countUppercase that takes a String array argument. You can assume that every element in the array is a one-letter String, for example String[] test = { "a", "B", "c", "D", "e"}; This method will count the number of uppercase letters from the set A through Z in the array, and return that number. So for the example array above, your method will return 2. You will need to use some Java library methods....
3. Write a Java method (called sumOfSquares) that reads in a sequence of integer numbers using a Scanner object. As each integer is read, the method displays that integer. The method also accumulates the sum of the squares of the integers and displays the sum when all integers are read. The method reads integers until a negative integer is read. The negative integer should not be display or added to the sum of squares. The method will not return a...
C++ Question 6 (10pt): Convert seconds Write a program that takes a number of seconds as user input (as an integer) and converts it to hours, minutes, and seconds as shown below. You should convert the amount of time in such a way that maximizes the whole numbers of hours and minutes. Expected output 1 (bold is user input) Enter a number of seconds: 60 0 hour(s) 1 minute(s) 0 second(s) Expected output 2 (bold is user input) Enter a...
PYTHON Write a program that converts a total number of seconds to hours, minutes, and seconds. It should (1) prompt the user for input, (2) read an integer from the keyboard, (3) and calculate the result. For example, "5000 seconds = 1 hours, 23 minutes, and 20 seconds". Hint: Use the modulus operator.
using C++ Write a program that: a) Inputs an integer n from the keyboard where n<=100. If n is out of range then print out an error message and ask for another input. This process repeats until a valid value for n is obtained. b) Inputs two 1D arrays of doubles A and B (of size n) from the keyboard. c) Inputs an integer k (from 1 to 3) from the keyboard. d) If k = 1 then it calculates...
Write a function called testneg with one input and no outputs. The function will test to see if the input value is negative. If it is negative, use fprintf to print the message to the screen Warning: The input value n is negative. where n is not literally the letter n, but is the value of the input to the function. Assume the input value is a floating-point number, so use an appropriate format in the fprintf to print the...