Answered step by step
Verified Expert Solution
Question
1 Approved Answer
This is my code and I keep getting this error i'm doing this in IntelliJ Idea CE and I'm not sure what the issue is.
This is my code and I keep getting this error i'm doing this in IntelliJ Idea CE and I'm not sure what the issue is.
Error: Could not find or load main class com.company.Main Caused by: java.lang.ClassNotFoundException: com.company.Main
package com.company; import java.util.Scanner; public class TimeInterpreter { static Scanner s = new Scanner(System.in).useDelimiter("\\s*:\\s*"); static final int SECONDS_IN_MINUTE = 60; static final int MINUTES_IN_HOUR = 60; public static void main(String[] args) { System.out.println("Enter time string (HH:MM:SS:) => "); int hour = s.nextInt(); int minute = s.nextInt(); int second = s.nextInt(); int totalSeconds = hour * MINUTES_IN_HOUR * SECONDS_IN_MINUTE; totalSeconds += minute * SECONDS_IN_MINUTE; totalSeconds += second; boolean negative = false; if (totalSeconds < 0) { negative = true; } System.out.println("Total time in seconds: " + totalSeconds); hour = Math.abs(totalSeconds / (MINUTES_IN_HOUR * SECONDS_IN_MINUTE)); totalSeconds = totalSeconds % (MINUTES_IN_HOUR * SECONDS_IN_MINUTE); minute = Math.abs(totalSeconds / (SECONDS_IN_MINUTE)); totalSeconds = totalSeconds % (SECONDS_IN_MINUTE); second = Math.abs(totalSeconds); System.out.println(" Your time => " + getTime(negative, hour, minute, second)); } private static String getTime(boolean negative, int hour, int minute, int second) { String s = ""; if (negative) { s += "-"; } if(hour != 0) { s += hour; s +=":"; } if(minute != 0) { s += minute; s +=":"; } if(second != 0) { s += second; s +=":"; } return s; } }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started