Win a copy of The Journey To Enterprise Agility this week in the Agile and Other Processes forum! And see the welcome thread for 20% off.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

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: 16084
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!
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!