473,508 Members | 2,210 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

can of coke, check whether opened or closed, contains 5 sips

2 New Member
Write a Java class CanOfCoke that represents information about cans of Coke. The following information is associated with each can:
• Whether or not the can has been opened
• The number of "sips" of drink remaining in it - initially this is 5 (when the can is full), and is 0 when the can has been emptied. 2 would indicate that 3 sips have been drunk.
Feb 6 '14 #1
3 1471
kanni313
2 New Member
guys reply me soon,it is very urgent and i couldn.t get the output
Feb 6 '14 #2
Nepomuk
3,112 Recognized Expert Specialist
Hi kani313 and welcome to bytes.com!

That sounds like the kind of task you would get in a programming beginners class, so I'm assuming this is your homework? We won't do your homework for you but if you show us what you've done so far and tell us what's wrong with it, we'll be happy to help you fix it.

Generally speaking you will need two simple data types: a boolean, which saves boolean values (which are true and false) and some kind of number, e.g. an int which saves an integer (0, 1, -1, 2, -2, ...).
Feb 7 '14 #3
mcupito
294 Contributor
Your question is also not very clear. Is the user going to be typing how many sips that have been taken?

There is too much ambiguity in your question for anyone to go with, and referring to @Nepomuk's post, no one will simply write a class for you.

I will try to help you, simply.

Expand|Select|Wrap|Line Numbers
  1. boolean open = false;
  2. int sip = 5;
  3.  
  4. If (open = false) 
  5.     ~WriteSomething "The can is unopened"
I'm going to leave the "sip" function up to you because I'm not sure how to handle it because of your lack of clarity in your OP. I think you know how to do it, just give it a try. If you fail, Google what you think you are doing wrong, and try it again.

What will happen (aside from your homework not being turned in on time) ? The computer will burst in flames and everyone will laugh? No. How else will you learn?
Feb 7 '14 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

6
4726
by: vishal | last post by:
hi i am building aan application which will send mail to user when he registers on my site and i am checking whther the email id is working properly or not by sending his email and then cheking...
1
21740
by: Siu | last post by:
Hi, in my ASP.NET (C#) application I would like to check in advance if a node exist: my code is as follow: XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(XML_FILENAME); XmlNode...
5
8414
by: zimmy | last post by:
Hi, Is it possible to check whether ASP.NET is installed on a machine, within a program that I'm writing in C#? And if it's installed, can I check if it is enabled? How? Thanks
2
2784
by: Nuno Magalhaes | last post by:
How to check for a closed http socket without losing any data? (MSDN says to send something to server). Somewhere in my code (after sending the http header in plain text) I'm doing a loop with:...
6
34617
by: Ros | last post by:
There are 10 files in the folder. I wish to process all the files one by one. But if the files are open or some processing is going on them then I do not want to disturb that process. In that case...
19
107859
Frinavale
by: Frinavale | last post by:
Filtering user input is extremely important for web programming. If input is left unfiltered users can input malicious code that can cripple your website. This article will explain how to make...
23
138212
by: mathewgk80 | last post by:
Hi all, I would like to get the Javascript code to check the textbox contains only numeric values or numbers.. I am using asp.net and c#.net.. Please help me.. Regards, Mathew
12
2212
by: foolsmart2005 | last post by:
There are 10 webpages on the host, e.g. 001.html, 002.html, 003,html, 004.html, ......010.html I want to check whether the page is the last page. How can I do. In the index.html -Go to last...
3
3551
by: kavitachawoor | last post by:
How to check popup window closed or with in that link button is clickedd or not.it mence-after displaying popup window if user close or click on link button with in the popup window the varible xyz...
3
3659
by: divyakgowda | last post by:
Hello everyone, My problem is, i am uploading a zipped file and extracting the contents and saving in a directory.How can i check whether the uploading zipped file contains only .swf files...
0
7231
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
7132
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
7336
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7401
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7504
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...
0
5640
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5059
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
4720
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
3211
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...

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.