![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: Nov 2006
Posts: 4
Rep Power: 0
![]() |
indentifier expected
i am a noob at java so my problem could quite possibly be really easy to fix
what im trying to do is get it so for a day in January it will display the day of week sunday being 0 and i keep gettin an identifier expected error import java.util.Scanner;
public class DayOfWeek
{
String dayName;
public int dayOfWeek1(int day);
{
dayOfWeek1 = (day - 1) % 7;
return dayOfWeek1;
}
public static void main(String[] args)
{
Scanner kb = new Scanner(System.in);
System.out.println("Enter Day in January (1-31): ");
int day = kb.nextInt();
if(dayOfWeek1 = 0)
{
dayName = "Sunday";
}
if(dayOfWeek1 = 1)
{
dayName = "Monday";
}
if(dayOfWeek1 = 2)
{
dayName = "Tuesday";
}
if(dayOfWeek1 = 3)
{
dayName = "Wednesday";
}
if(dayofWeek1 = 4)
{
dayName = "Thursday";
}
if(dayOfWeek1 = 5)
{
dayName = "Friday";
}
if(dayOfWeek1 = 6)
{
dayName = "Saturday";
}
}
system.out.println(dayName);
}Last edited by akbomber; Nov 13th, 2006 at 10:06 PM. |
|
|
|
|
|
#2 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
dayOfWeek1 is a function, not a variable. Break out your parentheses and toss in a couple, along with an argument.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
|
|
|
|
|
#3 |
|
Expert Programmer
Join Date: Jun 2005
Posts: 816
Rep Power: 4
![]() |
Also this line:
system.out.println(dayName); |
|
|
|
|
|
#4 |
|
Newbie
Join Date: Nov 2006
Posts: 4
Rep Power: 0
![]() |
lol like i said i am a complete noob
can u plz describe wut u mean more by that both of u id prob understand wut ur saying but i just dont no wut u mean by function and such |
|
|
|
|
|
#5 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
Break out the book. Maybe you could even find one written in AOL-speak, so you could understand it.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
|
|
|
|
|
#6 |
|
Newbie
Join Date: Nov 2006
Posts: 4
Rep Power: 0
![]() |
i love you to
|
|
|
|
|
|
#7 |
|
Programming Guru
![]() Join Date: Aug 2005
Location: England
Posts: 1,499
Rep Power: 4
![]() |
Before you learn how to program in a language, there is really a minimum of information you should know before asking questions. In Java, this is a class:
java Syntax (Toggle Plain Text)
java Syntax (Toggle Plain Text)
java Syntax (Toggle Plain Text)
java Syntax (Toggle Plain Text)
However, I'm not sure why I'm writing this, because there are far better places to learn the basics. Honestly, it's like asking why your car isn't working, and then asking simple questions like, "Tyre? What's a 'tyre'?". We can't help you if you don't know the absolute basics. Also, it helps if you speak using as good English as you can manage. This shows you're taking the effort to be understood, which encourages other people to take some effort to help you. If you can't be bothered to string together a valid sentence, why should people be bothered helping you? Also, programming languages typically require the programmer to strictly adhere to the syntax of the language. It might help for you to start practising on English, first. And if you're wondering why I'm saying this after I gave you some basic information; it's because I'm a helpful imbecile. However, even my patience has it's limits. |
|
|
|
|
|
#8 |
|
Newbie
Join Date: Nov 2006
Posts: 4
Rep Power: 0
![]() |
ok there you go i know what a method is i had not ever heard the term function before
|
|
|
|
|
|
#9 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
OK, there you go. I know what a method is. I had never heard the term, function, before.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
|
|
|
|
|
#10 |
|
Professional Programmer
Join Date: May 2005
Location: Bad Nauheim, Germany
Posts: 436
Rep Power: 4
![]() |
I was wondering what a term sounds like when it functions. Does it make a sound when it functions in a forest where there is no one to hear it?
__________________
-Steven "Is this a piece of your brain?" - Basil Fawlty |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| error: expected primary-expression... | rup | C++ | 18 | Apr 17th, 2006 2:24 PM |
| realloc not functioning as expected | nnxion | C | 24 | Nov 29th, 2005 6:20 PM |
| Total noob, trouble expected? | Mudanie | Python | 18 | Oct 27th, 2005 10:03 AM |
| Homework Problem 2 | Cup O' Java | Java | 3 | Mar 1st, 2005 11:46 PM |