Win a copy of Classic Computer Science Problems in Swift this week in the iOS forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Hey, i just started learning java and i'm stuck!  RSS feed

 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So i have an assignment to make a program that converts inputs of seconds,minutes and hours in a 60sec/min/hour format
Example: Input: 200s 200m 200h Output 20s 23m 203h
I've written that so far:



The Problem is when i compile it i get a ton of errors that i don't exactly know how to fix ;/ Please help
 
Java Cowboy
Sheriff
Posts: 16083
88
Android IntelliJ IDE Java Scala Spring
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch.

Java is case-sensitive. That means that System is not the same as system. Class System is written with a capital letter S. You've used the wrong name in lines 17, 18 and 19.

Class Scanner is in the package java.util. You have to import it to be able to use it. You need to have an import line at the top of the file:


The ; at the end, in line 22, must not be there.

For the rest, I don't see any syntax errors immediately.
 
Petar Stoyanov
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot! Fixed everything but one last error
"class main is public should be declared in a file named main.java"

As i said i did the Hello world tutorial before, didn't experience such error but now i do
 
Petar Stoyanov
Greenhorn
Posts: 21
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Petar Stoyanov wrote:Thanks a lot! Fixed everything but one last error
"class main is public should be declared in a file named main.java"

As i said i did the Hello world tutorial before, didn't experience such error but now i do



Nevermind I got it! The name of the public class should match the name of the file. fixed it and it works now!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!