Win a copy of Pro Spring MVC with WebFlux: Web Development in Spring Framework 5 and Spring Boot 2 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Rob Spoor
  • Bear Bibeault
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:
  • Frits Walraven
  • Himai Minh

Need help with code

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,
I need help with a project I am working on for school, what I need to do is create an application that helps a user select an ice cream cone flavor and how many scoops on the come. I managed to get the IceCreamconeException file to compile, however, I get error messages that states that an identifier is expected on about five lines when I try to compile the IceCreamCone file.Can anyone tell me exactly what this error message means. Any and all suggestions would be greatly appreciated, here are the error messages:

C:\Users\Owner\Documents\213191d_Ch15\Chapter.15>javac IceCreamCone.java
IceCreamCone.java:28: <identifier> expected
inputString = JOptionPane.showInputDialog(null, "What flavor of ice cream wou
ld you like?");
^
IceCreamCone.java:29: <identifier> expected
flavor = inputString;
^
IceCreamCone.java:32: <identifier> expected
inputString = JOptionPane.showInputDialog(null, "How many scoops of ice crea
m woul you like on your cone?");
^
IceCreamCone.java:33: <identifier> expected
scoops = Integer.parseInt(inputString);
^
IceCreamCone.java:36: illegal start of type
try
^
IceCreamCone.java:56: <identifier> expected
JOptionPane.showMessageDialog(null, "You chose" + flavor + "with" + scoops +
"of ice cream");

^
6 errors


[edit]Delete excess blank lines. CR[/edit]
[ December 03, 2008: Message edited by: Campbell Ritchie ]
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
those lines need to be inside a method (or constructor),
not dangling out amongst the class fields
 
Marshal
Posts: 72946
330
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You appear not to have taken note of what I told you yesterday about the setScoops method.
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic