473,669 Members | 2,386 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 1475
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
4731
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 whether the email was rebound or not. i know something about how to send email in php using mail function but not everything about sending email.
1
21835
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 nodeApplication = xmlDoc.SelectSingleNode(xmlPath); Before launching the instruction xmlDoc.SelectSingoleNode(xmlPath), how would like to check if my xmlPath exists in the Xml document... it is a soft
5
8423
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
2800
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: Loop:---------------- Socket.Receive //receive http data chunks Socket.Send //'/r/n' data to check if connection is active ------------------------ The problem is that when connection is closed by the http server, the send socket function...
6
34637
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 I would ignore processing that particular file and move to next file. How can I check whether the file is open or not? I tried os.stat and os.access but I am not getting the expected results. Also I checked in IO exceptions, IO error handler...
19
107946
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 sure that the user only submits a number to your .NET web application and also demonstrate how to add JavaScript to your ASPX pages. Upon popular demand, I have added a section that also covers how to use a validator control to check if a text box...
23
138284
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
2230
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 page,<---- I want to link this to the last page(010.html). Can I do it? How? Thanks!
3
3557
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 should set to 1 value. it meance if(popup.close==true) { xyz=1; } or if(popup.linkclick==true)
3
3663
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 inside, before or after extraction.Please help how can i do this? Its urgent. Thanks, amulyab
0
8465
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8383
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8895
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8809
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8588
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6210
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5682
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4386
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1788
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.