Forum     

Go Back   Digit Technology Discussion Forum > Bandwidth Wastage > Chit-Chat
Register FAQ Calendar Mark Forums Read

Chit-Chat General discussions about anything that doesn't fit into the other sections to be had here


Closed Thread
 
LinkBack Thread Tools Display Modes
Old 22-11-2007, 10:28 PM   #1 (permalink)
UBERGEEK
 
PCWORM's Avatar
 
Join Date: Dec 2005
Location: Oxford of da east
Posts: 395
Unhappy Can anyone write a program for me?


This question might feel a little dumb.. but im desperately in need of a program written to practice it
for my practical exam which is going to be held 2morrow.... im not stressing ne1 to help (coz this kind of help is not normally asked for)...im just
looking 4 ne1 who has sum time to help me......thnx in advance!!!!

the question for the program:

Write a program to declare a class 'Account' having data members as Account_no and Balance.
Accept this data for 10 accounts and display data of accounts having balance greater than 5000
__________________
And here comes the crysis killer: http://in.youtube.com/watch?v=Cd-LPHZcLNQ
PCWORM is offline  
Advertisements. Register and be a member of the community to get rid of them.
Advertisement

Old 22-11-2007, 10:36 PM   #2 (permalink)
die blizzard die! D3?
 
The_Devil_Himself's Avatar
 
Join Date: Aug 2007
Location: Event horizon
Posts: 2,361
Default Re: Can anyone write a program for me?

first of all this is not the section for your question.u should have used programming section.
__________________
Stealing your women and horses since 1843.

Last edited by The_Devil_Himself; 22-11-2007 at 10:46 PM.
The_Devil_Himself is offline  
Old 22-11-2007, 10:43 PM   #3 (permalink)
NP : Crysis
 
xbonez's Avatar
 
Join Date: Mar 2007
Location: City 17
Posts: 1,434
Default Re: Can anyone write a program for me?

oh! damn easy....and no constructors shouldn't be needed since u don't need to intialize a value. btw, r u in 12th??

m feeling too lazy to write prog now...sorry...will post in an hour or so...playing FEAR PM abhi...
__________________
Gaming: Phenom II x4 965BE @ 3.6Ghz/Corsair H50 Liquid Cooling/MSI 790FX-GD70/2x2GB GSkill Ripjaws 7-7-7-24/3 x GTX 470 w/Zalman VF3000F/Corsair 850W PSU/Antec 1200/2xSpinpoint F3 500Gb RAID 0
xbonez is offline  
Old 22-11-2007, 10:47 PM   #4 (permalink)
Wise Old Owl
 
harryneopotter's Avatar
 
Join Date: Feb 2007
Posts: 1,009
Default Re: Can anyone write a program for me?

i dnt see any need for constuctor here ...........

try this .....

Code:
#include<iostream.h>
#include<conio.h>
class Account {

         int Account_no,Balance;
    } holder[10];

void main()
{ int i ;

for (i=0; i<10;i++)
{cout<<"\nEnter account no for Account "<<i+1<<" :";
cin>>holder[i].Account_no;
cout<<"\nEnter Balance for this account :";
cin>>holder[i].Balance;
}

for(i=0; i<10;i++)
{if(holder[i].Balance>5000)
{cout<<"\nAccount No :"<<holder[i].Account_no;
cout<<"\tBalance :'<<holder[i].Balance;
}
}
getch();
}
try to run it as i havent checked it ....... let me knw if dsnt give the desired output.
harryneopotter is offline  
Old 22-11-2007, 11:18 PM   #5 (permalink)
die blizzard die! D3?
 
The_Devil_Himself's Avatar
 
Join Date: Aug 2007
Location: Event horizon
Posts: 2,361
Default Re: Can anyone write a program for me?

^^
Code:
ravi@ravi-desktop:~$ g++ 2.cpp
In file included from /usr/include/c++/4.1.3/backward/iostream.h:31,
                 from 2.cpp:1:
/usr/include/c++/4.1.3/backward/backward_warning.h:32:2: warning: #warning This file includes at least one deprecated or antiquated header. Please consider using one of the 32 headers found in section 17.4.1.2 of the C++ standard. Examples include substituting the <X> header for the <X.h> header for C++ includes, or <iostream> instead of the deprecated header <iostream.h>. To disable this warning use -Wno-deprecated.
2.cpp:2:18: error: conio.h: No such file or directory
2.cpp:21: error: missing terminating " character
2.cpp:8: error: ‘::main’ must return ‘int’
2.cpp: In function ‘int main()’:
2.cpp:5: error: ‘int Account::Account_no’ is private
2.cpp:13: error: within this context
2.cpp:5: error: ‘int Account::Balance’ is private
2.cpp:15: error: within this context
2.cpp:5: error: ‘int Account::Balance’ is private
2.cpp:19: error: within this context
2.cpp:5: error: ‘int Account::Account_no’ is private
2.cpp:20: error: within this context
2.cpp:22: error: expected primary-expression before ‘}’ token
2.cpp:22: error: expected `;' before ‘}’ token
2.cpp:24: error: ‘getch’ was not declared in this scope
ravi@ravi-desktop:~$
???
__________________
Stealing your women and horses since 1843.
The_Devil_Himself is offline  
Old 23-11-2007, 12:00 AM   #6 (permalink)
Wahahaha~!
 
Faun's Avatar
 
Join Date: Dec 2006
Location: Pune/there
Posts: 7,673
Default Re: Can anyone write a program for me?

Quote:
Originally Posted by harryneopotter
i dnt see any need for constuctor here ...........

try this .....

Code:
#include<iostream.h>
#include<conio.h>
class Account {

         int Account_no,Balance;
    } holder[10];

void main()
{ int i ;

for (i=0; i<10;i++)
{cout<<"\nEnter account no for Account "<<i+1<<" :";
cin>>holder[i].Account_no;
cout<<"\nEnter Balance for this account :";
cin>>holder[i].Balance;
}

for(i=0; i<10;i++)
{if(holder[i].Balance>5000)
{cout<<"\nAccount No :"<<holder[i].Account_no;
cout<<"\tBalance :'<<holder[i].Balance;
}
}
getch();
}
try to run it as i havent checked it ....... let me knw if dsnt give the desired output.
Use getter and setter method to access private variable, u r violating the concept of encapsulation

Dont use conio.h - its not ANSI compliant

Use int main() and put a return 0; at the program end

NOTE: These r just my intrepretations
__________________
Blog | Flickr | Battlelog
Spoiler:
Asus Z68 V-Pro|i5 2500k|TRUE Black|Ripjaws X|U2311H|N560GTX|D7000|XONAR STX|RE272|RE0|CC51|XE200PRO Walnut| TD II V2| Ultraphile|N5800

Mono
Faun is online now  
Old 23-11-2007, 12:02 AM   #7 (permalink)
die blizzard die! D3?
 
The_Devil_Himself's Avatar
 
Join Date: Aug 2007
Location: Event horizon
Posts: 2,361
Default Re: Can anyone write a program for me?

^^hey T159 can you debug this program and post the working one please.
__________________
Stealing your women and horses since 1843.
The_Devil_Himself is offline  
Old 23-11-2007, 12:24 AM   #8 (permalink)
Wahahaha~!
 
Faun's Avatar
 
Join Date: Dec 2006
Location: Pune/there
Posts: 7,673
Default Re: Can anyone write a program for me?

#include<iostream.h>
#include<stdio.h>

class Account {
//private members cant be accessed outside class directly
private:
int accountNo,balance;

//instead use getter and setter methods to access variable
public:
void setAccountNo(int accountNo)
{
this->accountNo = accountNo;
}

void setBalance(int balance)
{
this->balance = balance;
}

int getAccountNo()
{
return (accountNo);
}

int getBalance()
{
return(balance);
}
} holder[10]; //creates 10 references of class account as an array

int main()
{
int i,accountNo,balance;

//this loop take the values in each object variables
for (i=0; i<10;i++)
{
cout<<"\nEnter account no for Account "<<i+1<<" :";
cin>>accountNo;
holder[i].setAccountNo(accountNo);

cout<<"\nEnter Balance for this account :";
cin>>balance;
holder[i].setBalance(balance);
}

for(i=0; i<10;i++)
{
if(holder[i].getBalance()>5000)
{
cout<<"\nAccount No :"<<holder[i].getAccountNo();
cout<<"\tBalance :'"<<holder[i].getBalance();
}
}

getchar();
return(0);
}

///////////////////////////
/* this will work surely but u might consider using file operations and be sure if u want to clear screen then include conio.h and use clrscr (though i wouldnt recommend doing this), my fingers are aching am quitting now*/

Quote:
Originally Posted by The_Devil_Himself
^^hey T159 can you debug this program and post the working one please.
done man
__________________
Blog | Flickr | Battlelog
Spoiler:
Asus Z68 V-Pro|i5 2500k|TRUE Black|Ripjaws X|U2311H|N560GTX|D7000|XONAR STX|RE272|RE0|CC51|XE200PRO Walnut| TD II V2| Ultraphile|N5800

Mono

Last edited by Faun; 23-11-2007 at 12:24 AM. Reason: Automerged Doublepost
Faun is online now  
Old 23-11-2007, 12:25 AM   #9 (permalink)
die blizzard die! D3?
 
The_Devil_Himself's Avatar
 
Join Date: Aug 2007
Location: Event horizon
Posts: 2,361
Default Re: Can anyone write a program for me?

it works perfectly.Thanks a lot T159.
__________________
Stealing your women and horses since 1843.
The_Devil_Himself is offline  
Old 23-11-2007, 12:27 AM   #10 (permalink)
Wahahaha~!
 
Faun's Avatar
 
Join Date: Dec 2006
Location: Pune/there
Posts: 7,673
Default Re: Can anyone write a program for me?

Quote:
Originally Posted by The_Devil_Himself
it works perfectly.Thanks a lot T159.
__________________
Blog | Flickr | Battlelog
Spoiler:
Asus Z68 V-Pro|i5 2500k|TRUE Black|Ripjaws X|U2311H|N560GTX|D7000|XONAR STX|RE272|RE0|CC51|XE200PRO Walnut| TD II V2| Ultraphile|N5800

Mono
Faun is online now  
Closed Thread

Bookmarks

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
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Cannot write... soumya QnA (read only) 5 27-06-2007 08:37 PM
cannot write more than 32X gau_pppu Hardware Q&A 4 08-12-2006 02:25 PM
HOW TO WRITE A CD mandar5 QnA (read only) 18 17-08-2005 07:50 PM
How to write a video dvd?? deadmanrulz Software Q&A 4 04-05-2005 10:57 PM
new program in 'close program menu' list and more....... vishakadatta QnA (read only) 2 12-04-2005 11:33 PM

 
Latest Threads
- by bhaskar
- by kool
- by Who
- by Tenida
- by Charan

Advertisement




All times are GMT +5.5. The time now is 10:14 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.

Search Engine Optimization by vBSEO 3.3.2