473,494 Members | 2,223 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Need help getting started with program .....

i took a c++ intro cs course a few years back and recently decided to
major in cs after much switching back and forth between majors. it
seems my school has replaced most of it's intro level cs courses to
java making c++ obsolete! whether this is a good idea or not that is a
discussion for another day. anyway learning a new language is never
easy and the professor has assigned the following problem to us and i
am completely lost! if anyone can push me in the right direction in
writing this program i'd highly appreciate it.

--
Design and implement the class Day that implements the day of the week
in a program. The class Day should store the day, such as Sun for
Sunday. The program should be able to perform the following operations
on an object of the type Day:

a) Set the day
b) Print the day
c) Return the day
d) Return the next day
e) Return the previous day
f) Calculate and return a day by adding # of days to current day.
(ie. if current day is Monday and we add 3 days then new day
is Thursday)
g) Add the appropiate constructors // default & set constructors
h) Write the definitins of the methods to implement the
operations for the class Day as defined in a - g
i) Write a program to test various operations on the class Day
/* here is what i've done so far .. not much but you got to start
somewhere correct me if i'm wrong */

class week {
string [] days = {"mon","tue","wed","thu","fri","sat","sun"};
// set the days
int i = 0;
for (i < 8; i++ ) {
System.out.print(days[i]); // print days using index?
}

public class returnDays {
return days[];
}

/* that's as far as i've gotten so far.. any help would be
highly appreciated can someone explain to me what exactly
the constructors job is? also how to properly use an
index because i know i screwed that up.. */

Jul 17 '05 #1
1 3580

"coolcsgeek" <co********@yahoo.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
i took a c++ intro cs course a few years back and recently decided to
major in cs after much switching back and forth between majors. it
seems my school has replaced most of it's intro level cs courses to
java making c++ obsolete! whether this is a good idea or not that is a
discussion for another day. anyway learning a new language is never
easy and the professor has assigned the following problem to us and i
am completely lost! if anyone can push me in the right direction in
writing this program i'd highly appreciate it.

--
Design and implement the class Day that implements the day of the week
in a program. The class Day should store the day, such as Sun for
Sunday. The program should be able to perform the following operations
on an object of the type Day:

a) Set the day
b) Print the day
c) Return the day
d) Return the next day
e) Return the previous day
f) Calculate and return a day by adding # of days to current day.
(ie. if current day is Monday and we add 3 days then new day
is Thursday)
g) Add the appropiate constructors // default & set constructors
h) Write the definitins of the methods to implement the
operations for the class Day as defined in a - g
i) Write a program to test various operations on the class Day
/* here is what i've done so far .. not much but you got to start
somewhere correct me if i'm wrong */

class week {
string [] days = {"mon","tue","wed","thu","fri","sat","sun"};
// set the days
int i = 0;
for (i < 8; i++ ) {
System.out.print(days[i]); // print days using index?
}

public class returnDays {
return days[];
}

/* that's as far as i've gotten so far.. any help would be
highly appreciated can someone explain to me what exactly
the constructors job is? also how to properly use an
index because i know i screwed that up.. */

Actually your indexed array access is syntactically correct. But you can't put
code directly in a class. You have to write methods. Your returnDays class
especially should be a method. Further, your assignment was to write a Day
class. You don't even have the word "Day" in your code. Start by reading some of
your textbook. Otherwise you can start here:
http://java.sun.com/docs/books/tutorial/

Finally, in the future do not crosspost among the comp.lang.java.* groups, and
do not post at all to comp.lang.java. That group is deprecated. Your posts would
be better received in comp.lang.java.help, which is a group for beginners.
Jul 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

80
5175
by: Bibby | last post by:
Hi, I'm interested in getting started in the programming world. I've dabbled in C, C++ and VB6. Which would be the best language to focus my attention to regarding the following considerations: ...
1
1476
by: bigcjr44 | last post by:
I have an assignment do tonite and I can not get it started. We are learning about recursion. This is my assignment, and this is what I have written, could someone please tell me what I am doing...
4
1132
by: goldbond_8 | last post by:
I am looking to learn VB.net. I have been programming in VB6 for about 3 years but have not done much Object Oriented Programming. I know VB.Net is much different from VB6, so my question is,...
0
1737
by: biganimal | last post by:
I have a program and I want the program to be able to save question/answers so the program actually gets smarter without getting amnesia everytime its started. Can anyone help??? # questor.py ...
2
2685
by: lifeshortlivitup | last post by:
I am a java beginner and am trying to tackle a temperature conversion problem but I don't exactly know how to begin. The problem asks that I write a program that allows the user to conver either...
0
3917
by: U S Contractors Offering Service A Non-profit | last post by:
Brilliant technology helping those most in need Inbox Reply U S Contractors Offering Service A Non-profit show details 10:37 pm (1 hour ago) Brilliant technology helping those most in need ...
12
2980
by: adamurbas | last post by:
ya so im pretty much a newb to this whole python thing... its pretty cool but i just started today and im already having trouble. i started to use a tutorial that i found somewhere and i followed...
5
7919
by: Chuck Anderson | last post by:
I run Apache 2.0.55, and Php (both 4.4.1 and 5.2.5) on my home PC (Windows XP). One of the scripts that I run daily needs to access a secure URL (https://..............). When I am running Php4,...
0
1430
by: Dale | last post by:
Access 2000 I have a check scanner from Magtek, (MicrImage) This is like a "point of sale" check scanner/credit card reader. Magtek furnished 2 ocx's (MTMicrImage.ocx & SaxComm8.ocx). They also...
0
7119
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
6989
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7367
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
4889
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4579
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3078
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1400
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
644
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
285
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.