0 Members and 1 Guest are viewing this topic.
import javax.swing.JOptionPane;public class Time{ public static void main (String[] args) { String hour; String minute; String second; hour = JOptionPane.showInputDialog("Enter number of hours:"); minute = JOptionPane.showInputDialog("Enter number of minutes:"); second = JOptionPane.showInputDialog("Enter number of seconds:"); int hourint = Integer.parseInt(hour); int minuteint = Integer.parseInt(minute); int secondint = Integer.parseInt(second); hourint = hourint * 60 * 60; minuteint = minuteint * 60; secondint = secondint + minuteint + hourint; JOptionPane.showMessageDialog(null,"here is your number of seconds:"); JOptionPane.showMessageDialog(null,secondint); //second half of code: take seconds convert into hours, mins, and seconds. String secondint2 = JOptionPane.showInputDialog("Enter number of seconds to convert into hours, minutes, and seconds:"); secondint = Integer.parseInt(secondint2); hourint = secondint / 60; hourint = hourint / 60; int hoursecondint = hourint * 60 * 60; secondint = secondint - hoursecondint; minuteint = secondint / 60; int minutesecondint = secondint * 60; secondint = secondint - minutesecondint; JOptionPane.showMessageDialog(null,hourint); JOptionPane.showMessageDialog(null,minuteint); JOptionPane.showMessageDialog(null,secondint); }}
int secondint = secondint2 % 60;secondint2 = (secondint2-secondint)/60;int minuteint = secondint2 % 60;secondint2 = (secondint2-minuteint)/60;int hourint = secondint2;
Alright ill try that then.. although i dont want to since its not my work and I would rather have an explanation but thanks anyhow
mods can be really helpful sometimes.
--------------------Configuration: <Default>--------------------F:\adv. comp sci\New folder\Time.java:27: operator % cannot be applied to java.lang.String,int secondint = secondint2 % 60; ^F:\adv. comp sci\New folder\Time.java:29: operator % cannot be applied to java.lang.String,int minuteint = secondint2 % 60; ^2 errorsProcess completed.
import javax.swing.JOptionPane;public class Time{ public static void main (String[] args) { String hour; String minute; String second; hour = JOptionPane.showInputDialog("Enter number of hours:"); minute = JOptionPane.showInputDialog("Enter number of minutes:"); second = JOptionPane.showInputDialog("Enter number of seconds:"); int hourint = Integer.parseInt(hour); int minuteint = Integer.parseInt(minute); int secondint = Integer.parseInt(second); hourint = hourint * 60 * 60; minuteint = minuteint * 60; secondint = secondint + minuteint + hourint; JOptionPane.showMessageDialog(null,"here is your number of seconds:"); JOptionPane.showMessageDialog(null,secondint); //second half of code: take seconds convert into hours, mins, and seconds. String secondint2 = JOptionPane.showInputDialog("Enter number of seconds to convert into hours, minutes, and seconds:"); int secondint3 = Integer.parseInt(secondint2); secondint = secondint2 % 60; //1st error secondint3 = (secondint3 - secondint)/60; minuteint = secondint2 % 60; //2nd error secondint3 = (secondint3 - minuteint)/60; hourint = secondint2; JOptionPane.showMessageDialog(null,hourint); JOptionPane.showMessageDialog(null,minuteint); JOptionPane.showMessageDialog(null,secondint); }}
int secondint2 = Integer.parseInt(JOptionPane.showInputDialog("Enter number of seconds to convert into hours, minutes, and seconds:"));
import javax.swing.JOptionPane;public class Time{ public static void main (String[] args) { String hour; String minute; String second; hour = JOptionPane.showInputDialog("Enter number of hours:"); minute = JOptionPane.showInputDialog("Enter number of minutes:"); second = JOptionPane.showInputDialog("Enter number of seconds:"); int hourint = Integer.parseInt(hour); int minuteint = Integer.parseInt(minute); int secondint = Integer.parseInt(second); hourint = hourint * 60 * 60; minuteint = minuteint * 60; secondint = secondint + minuteint + hourint; JOptionPane.showMessageDialog(null,"here is your number of seconds:"); JOptionPane.showMessageDialog(null,secondint); //second half of code: take seconds convert into hours, mins, and seconds. String secondint2 = JOptionPane.showInputDialog("Enter number of seconds to convert into hours, minutes, and seconds:"); int secondint3 = Integer.parseInt(secondint2); secondint = secondint3 % 60; secondint3 = (secondint3 - secondint)/60; minuteint = secondint3 % 60; secondint3 = (secondint3 - minuteint)/60; hourint = secondint3; JOptionPane.showMessageDialog(null,hourint); JOptionPane.showMessageDialog(null,minuteint); JOptionPane.showMessageDialog(null,secondint3); }}