Win a copy of Spring in Action (5th edition) this week in the Spring forum!
  • 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:
  • Campbell Ritchie
  • Bear Bibeault
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

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
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!
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!