Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Nov 13th, 2006, 10:28 PM   #1
akbomber
Newbie
 
Join Date: Nov 2006
Posts: 4
Rep Power: 0 akbomber is on a distinguished road
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 11:06 PM.
akbomber is offline   Reply With Quote
Old Nov 13th, 2006, 10:56 PM   #2
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
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
DaWei is offline   Reply With Quote
Old Nov 13th, 2006, 11:01 PM   #3
The Dark
Expert Programmer
 
Join Date: Jun 2005
Posts: 894
Rep Power: 4 The Dark is on a distinguished road
Also this line:
	system.out.println(dayName);
Needs to be inside a function.
The Dark is offline   Reply With Quote
Old Nov 13th, 2006, 11:03 PM   #4
akbomber
Newbie
 
Join Date: Nov 2006
Posts: 4
Rep Power: 0 akbomber is on a distinguished road
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
akbomber is offline   Reply With Quote
Old Nov 13th, 2006, 11:06 PM   #5
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
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
DaWei is offline   Reply With Quote
Old Nov 13th, 2006, 11:11 PM   #6
akbomber
Newbie
 
Join Date: Nov 2006
Posts: 4
Rep Power: 0 akbomber is on a distinguished road
i love you to
akbomber is offline   Reply With Quote
Old Nov 14th, 2006, 3:42 AM   #7
Arevos
Programming Guru
 
Arevos's Avatar
 
Join Date: Aug 2005
Location: England
Posts: 1,499
Rep Power: 5 Arevos is on a distinguished road
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)
  1. class DayOfWeek
  2. {
  3. }
This is the definition of a function, also known as a method:
java Syntax (Toggle Plain Text)
  1. String fooey(String s)
  2. {
  3. return s + "? Fooey!";
  4. }
This method takes in a string as input, and returns a string as output. In Java, all methods have to be defined inside a class. This is a variable:
java Syntax (Toggle Plain Text)
  1. String name = "Churchill";
Variables can be defined in a class, or in a method. This is a method call:
java Syntax (Toggle Plain Text)
  1. System.out.println("Hello World");
Generally speaking, a method call should be called from another method. The method with the name "main" will be called automatically when the program starts.

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.
Arevos is offline   Reply With Quote
Old Nov 14th, 2006, 8:37 AM   #8
akbomber
Newbie
 
Join Date: Nov 2006
Posts: 4
Rep Power: 0 akbomber is on a distinguished road
ok there you go i know what a method is i had not ever heard the term function before
akbomber is offline   Reply With Quote
Old Nov 14th, 2006, 9:08 AM   #9
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
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
DaWei is offline   Reply With Quote
Old Nov 14th, 2006, 6:04 PM   #10
stevengs
Professional Programmer
 
stevengs's Avatar
 
Join Date: May 2005
Location: Bad Nauheim, Germany
Posts: 436
Rep Power: 4 stevengs is on a distinguished road
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
stevengs is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
error: expected primary-expression... rup C++ 18 Apr 17th, 2006 3:24 PM
realloc not functioning as expected nnxion C 24 Nov 29th, 2005 7:20 PM
Total noob, trouble expected? Mudanie Python 18 Oct 27th, 2005 11:03 AM
Homework Problem 2 Cup O' Java Java 3 Mar 2nd, 2005 12:46 AM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 11:57 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC