Assignment Regarding C++

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Aug 2009
Posts: 2
Reputation: Schwein is an unknown quantity at this point 
Solved Threads: 0
Schwein Schwein is offline Offline
Newbie Poster

Assignment Regarding C++

 
0
  #1
Aug 2nd, 2009
Can Someone help me regarding my C++ Assignments? I'll list the questions below:

ASSIGNMENT 1

Assume the array in the following table represents the monthly rental price of six resort cabins over a five-year period.

YEAR
2005 2006 2007 2008 2009

1 200 210 225 300 235
2 250 465 343 255 344
CABIN 3 233 333 453 268 365
4 200 325 400 333 222
5 200 160 642 674 358

Write a program that employs functions to perform the following tasks:

i. Fill a two-dimensional array with the above table
ii. Compute the total rental income for each cabin by year and store the yearly totals in a second array.

ASSIGNMENT 2

An International Standard Book Number (ISBN) is a code of 10 characters separated by dashes such as 0-8065-0959-7.

An ISBN consists of four parts : a group code, a publisher code, a code that uniquely identifies the book among those published by the particular publisher, and a check character.

For the ISBN 0-8065-0959-7, the group code is 0, which identifies the book as one from and English-speaking country.

The publisher code 8065 identifies the book as one published by Citadel Press. The code 0959 uniquely identifies the book among those published by Citadel Press ( Brode: Woody Allen : His Films and Career, in this case ).

The check character is computed as follows: First compute the sum of the first digit plus two times the second digit plus three times the third digit,……, plus nine times the ninth digit. The last character is the remainder when the sum is divided by 11. If the remainder is 10, the last character is X which is considered as invalid ISBN number. For example, the sum for the ISBN 0-8065-0959-7 is 0 + 2*8 + 3*0 + 4*6 + 5*5 + 6*0 + 7*9 + 8*5 + 9*9 = 249. The remainder when 249 is divided by 11 is 7, the last character in the ISBN. The check character is use to validate an ISBN.

Write a program that uses one function that receive one parameter s that is an array of characters. The function returns 1 (true) if the array represents a valid ISBN and 0 (false) otherwise.

ASSIGNMENT 3

Write a modular program (function) for problem given below.

This program will let you enter the initial balance for the month, followed by a series of transactions. There is no limit on the number of transactions the program can process. A transaction takes the form of two input values: a single letter, followed by a float number. If the letter is:

C, then the number is the amount for a check (withdrawal)
D, then the number is the amount for a deposit
E, this is a sentinel value to signal the end of input

For each transaction entered, the program will echo-print the transaction data, the current balance for the account ( not including deductions for service charges ), the service charge for the transaction, and the total accumulated service charges for all transactions. After the end sentinel is processed, the program will print the current balance, total service charges, and the closing balance (balance after deducting service charges ).

Service charges are:
• Check fee : $0.15 for each check (withdrawal )
• Deposit fee : $0.10 for each deposit
• Low balance fee : if the balance drops below $500.00 at any point during the month, a service charge of $5.00 is assessed for the month ( one time only ).
• If the balance drops below $50.00, the program prints a warning message, but no fee is charged.
• Overdrawn balance fee : if the balance becomes negative, an additional service charge of $10.00 must be assessed for each check until the balance becomes positive again.

ASSIGNMENT 4

ASSIGNMENT 6 (ARRAYS)


Write a program to assign passengers seats in an airplane. Assume a small airplane with seat numbering as follows :

1 A B C D
2 A B C D
3 A B C D
4 A B C D
5 A B C D
6 A B C D
7 A B C D

The program should display the seat pattern, with an 'X' marking the seat already assigned. For example, after seats 1A, 2B, and 4C are taken, the display should look like :

1 X B C D
2 A X C D
3 A B C D
4 A B X D
5 A B C D
6 A B C D
7 A B C D

After displaying the seats available, the program prompts for the seat desired, the user types in a seat, then the display of available seats is updated. This continues until all seats are filled or until the user signals that the program should end. If the user types in a seat that is already assigned, the program should say that the seat is occupied and ask for another choice.
Last edited by Schwein; Aug 2nd, 2009 at 3:56 am.
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 675
Reputation: Sky Diploma is a splendid one to behold Sky Diploma is a splendid one to behold Sky Diploma is a splendid one to behold Sky Diploma is a splendid one to behold Sky Diploma is a splendid one to behold Sky Diploma is a splendid one to behold 
Solved Threads: 99
Sky Diploma's Avatar
Sky Diploma Sky Diploma is offline Offline
Practically a Master Poster

Re: Assignment Regarding C++

 
1
  #2
Aug 2nd, 2009
Wow......... Nice Assignments......... Have fun solving
1. Please Mark Your Thread as Solved After Getting Your Answers.
2. Please Use CODE TAGS .
Reply With Quote Quick reply to this message  
Join Date: Jun 2007
Posts: 1,377
Reputation: evstevemd has a spectacular aura about evstevemd has a spectacular aura about evstevemd has a spectacular aura about 
Solved Threads: 127
evstevemd's Avatar
evstevemd evstevemd is offline Offline
Nearly a Posting Virtuoso

Re: Assignment Regarding C++

 
1
  #3
Aug 2nd, 2009
What have you done so far?
Remember we have to help you get somewhere, but you must have something
Atheist: God is man made imagination, he doesn't exist!
Theist: It's okay, can you imagine anything else that doesn't exist?
Junior MD --- Python, C++ and PHP
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 1,204
Reputation: firstPerson is just really nice firstPerson is just really nice firstPerson is just really nice firstPerson is just really nice 
Solved Threads: 149
firstPerson's Avatar
firstPerson firstPerson is offline Offline
Nearly a Posting Virtuoso

Re: Assignment Regarding C++

 
0
  #4
Aug 2nd, 2009
very cute.
Reply With Quote Quick reply to this message  
Join Date: Aug 2009
Posts: 2
Reputation: Schwein is an unknown quantity at this point 
Solved Threads: 0
Schwein Schwein is offline Offline
Newbie Poster

Re: Assignment Regarding C++

 
0
  #5
Aug 2nd, 2009
Originally Posted by evstevemd View Post
What have you done so far?
Remember we have to help you get somewhere, but you must have something
Well for assignment 1, I have done the following. The problem is about displaying the output. It's some sort of messy, have no idea on how sorting it anymore.

#include <iostream.h>
main()
{
int cabin[5][5]={{200,210,225,300,235},
{250,465,343,255,344},
{233,333,453,268,365},
{200,325,400,333,222},
{200,160,642,674,358}};

char choose;

int total[5][5];

int i,j,m,n;


for(i=0;i<5;i++)
{
for(j=0;j<5;j++)

cout<<cabin[i][j]<<" ";
cout<<"\n";

}

cout<<"\nPress C (Capital C) to Calculate The Yearly Income For All Cabin ";
cin>>choose;

if (choose == 'C')
{
for(i=0;i<5;i++)
{
for (j=0;j<5;j++)
{
total[i][j]= cabin[i][j]*12;
cout<<total[i][j]<<" ";
cout<<"\n";

}

}
for(i=0;i<5;i++)
{
for (j=0;j<5;j++)
{
cout<<total[i][j]<<" ";
cout<<"\n";
}
}
}



}







else
cout<<"Can't You Read? Capital C Only!!!!"<<endl;



return 0;
}


For Assignment 2, I'm still making it. >.<

For Assignment 3, I have done the following. Yes, the program is not working as I have no idea where and what is the mistake. >.<

#include <iostream.h>

#define CF 0.15
#define DF 0.10
#define LB 5.00
#define OD 10.00


float result(char transaction, float balance, float amount);

void main ()

{

float b, a, i;
char t;

cout<<"\nWelcome To Mike's Banking";
cout<<"\nChoose C for withdrawal";
cout<<"\nChose D for deposit";
cout<<"\nChoose E for end of input";

cout<<"\n\nWhat's Your Current Balance";
cin>>b;
cout<<"\nWhat Transaction You Want To Do: ";
for (i=1; i>0; i++)
{
cin>>t;
}
cout<<"\nWhat's The Amount You Want To Involve: ";
cin>>a;

if (t == 'C')
{
cout<<"\nYour Current Account Balance Is: "<<b;
cout<<"\nYou Have Chosen To Withdraw Money";
cout<<"\nYour Check Fee Is $0.15";
for (i=0; i<1; i++);
{
if (b < 500)
cout<<"There's A Low Balance Fee $For 500.00";
}
for (i=0; i<1; i++);
{
if (b < 50)
cout<<"Your Balance Is Below 50 Dollars";
}

}


else if (t == 'D')
{
cout<<"\nYour Current Account Balance Is: "<<b;
cout<<"\nYou Have Chosen To Deposit Money";
cout<<"\nYour Deposit Fee Is $0.10";
for (i=0; i<1; i++);
{
if (b < 0)
cout<<"There's An Overdrawn balance fee for $10.00";
}
for (i=0; i<1; i++);
{
if (b < 50)
cout<<"Your Balance Is Below 50 Dollars";
}
}

else if (t == 'E')
{
cout<<"\nYou Have Chosen to end the transaction";
cout<<"\nYour Initial Balance Was: "<<b;
cout<<"\nYour Total Service Charges Is: ";
cout<<"\nYour End Balance Is: "<<result;
}

else
cout<<"Choose A Choice man!";


}

float result(char transaction, float balance, float amount)
{
char t;
float i, b, a;
if (t == 'C')
{
for (i=0;i<1;i++);
{
if ( b < 0 && b < 500)
{
result = b + a - 0.15 - 5;
return result;
}
else if ( b < 500)
{
result = b + a - 5;
return result;
}
else if (b < 0)
{
result = b + a - 0.15;
return result;
}
}
}

if (t == 'D')
{
for (i=0;i<1;i++);
{
if ( b < 0 && b < 500)
{
result = b + a - 0.10 - 5;
return;
}
else if ( b < 500)
{
result = b + a - 5;
return;
}
else if (b < 0)
{
result = b + a - 0.10;
return;
}
}
}


}


For Assignment 4, I have only done the first output. I have no idea on doing the calculation and the final output. >.<

#include <iostream.h>
main()
{
char seat[7][5]= {{'1','A','B','C','D'}, {'3','A','B','C','D'}, {'3','A','B','C','D'}, {'4','A','B','C','D'}, {'5','A','B','C','D'}, {'6','A','B','C','D'}, {'7','A','B','C','D'}};

int i,j, sr,
char sc;


for(i=0;i<7;i++)
{
for(j=0;j<5;j++)

cout<<seat[i][j]<<" ";
cout<<"\n";

}
cout<<"\nPlease Pick The Seat's Number";
cin>>sr;
cout<<"\nPlease Pick The Seat's Place";
cin>>sc;
return 0;
}

Any kind of help on any kind of assignments are really appreciated..
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 3,819
Reputation: VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute 
Solved Threads: 501
Featured Poster
VernonDozier VernonDozier is offline Offline
Senior Poster

Re: Assignment Regarding C++

 
0
  #6
Aug 2nd, 2009
Code tags. Use them. Here's how. I've put your code in tags this one time.


[code]
// paste code here
[/code]

or

[code=cplusplus]
// paste code here
[/code]


Originally Posted by Schwein View Post
Well for assignment 1, I have done the following. The problem is about displaying the output. It's some sort of messy, have no idea on how sorting it anymore.
  1. #include <iostream.h>
  2. main()
  3. {
  4. int cabin[5][5]={{200,210,225,300,235},
  5. {250,465,343,255,344},
  6. {233,333,453,268,365},
  7. {200,325,400,333,222},
  8. {200,160,642,674,358}};
  9.  
  10. char choose;
  11.  
  12. int total[5][5];
  13.  
  14. int i,j,m,n;
  15.  
  16.  
  17. for(i=0;i<5;i++)
  18. {
  19. for(j=0;j<5;j++)
  20.  
  21. cout<<cabin[i][j]<<" ";
  22. cout<<"\n";
  23.  
  24. }
  25.  
  26. cout<<"\nPress C (Capital C) to Calculate The Yearly Income For All Cabin ";
  27. cin>>choose;
  28.  
  29. if (choose == 'C')
  30. {
  31. for(i=0;i<5;i++)
  32. {
  33. for (j=0;j<5;j++)
  34. {
  35. total[i][j]= cabin[i][j]*12;
  36. cout<<total[i][j]<<" ";
  37. cout<<"\n";
  38.  
  39. }
  40.  
  41. }
  42. for(i=0;i<5;i++)
  43. {
  44. for (j=0;j<5;j++)
  45. {
  46. cout<<total[i][j]<<" ";
  47. cout<<"\n";
  48. }
  49. }
  50. }
  51.  
  52.  
  53.  
  54. }
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62. else
  63. cout<<"Can't You Read? Capital C Only!!!!"<<endl;
  64.  
  65.  
  66.  
  67. return 0;
  68. }

For Assignment 2, I'm still making it. >.<

For Assignment 3, I have done the following. Yes, the program is not working as I have no idea where and what is the mistake. >.<
  1. #include <iostream.h>
  2.  
  3. #define CF 0.15
  4. #define DF 0.10
  5. #define LB 5.00
  6. #define OD 10.00
  7.  
  8.  
  9. float result(char transaction, float balance, float amount);
  10.  
  11. void main ()
  12.  
  13. {
  14.  
  15. float b, a, i;
  16. char t;
  17.  
  18. cout<<"\nWelcome To Mike's Banking";
  19. cout<<"\nChoose C for withdrawal";
  20. cout<<"\nChose D for deposit";
  21. cout<<"\nChoose E for end of input";
  22.  
  23. cout<<"\n\nWhat's Your Current Balance";
  24. cin>>b;
  25. cout<<"\nWhat Transaction You Want To Do: ";
  26. for (i=1; i>0; i++)
  27. {
  28. cin>>t;
  29. }
  30. cout<<"\nWhat's The Amount You Want To Involve: ";
  31. cin>>a;
  32.  
  33. if (t == 'C')
  34. {
  35. cout<<"\nYour Current Account Balance Is: "<<b;
  36. cout<<"\nYou Have Chosen To Withdraw Money";
  37. cout<<"\nYour Check Fee Is $0.15";
  38. for (i=0; i<1; i++);
  39. {
  40. if (b < 500)
  41. cout<<"There's A Low Balance Fee $For 500.00";
  42. }
  43. for (i=0; i<1; i++);
  44. {
  45. if (b < 50)
  46. cout<<"Your Balance Is Below 50 Dollars";
  47. }
  48.  
  49. }
  50.  
  51.  
  52. else if (t == 'D')
  53. {
  54. cout<<"\nYour Current Account Balance Is: "<<b;
  55. cout<<"\nYou Have Chosen To Deposit Money";
  56. cout<<"\nYour Deposit Fee Is $0.10";
  57. for (i=0; i<1; i++);
  58. {
  59. if (b < 0)
  60. cout<<"There's An Overdrawn balance fee for $10.00";
  61. }
  62. for (i=0; i<1; i++);
  63. {
  64. if (b < 50)
  65. cout<<"Your Balance Is Below 50 Dollars";
  66. }
  67. }
  68.  
  69. else if (t == 'E')
  70. {
  71. cout<<"\nYou Have Chosen to end the transaction";
  72. cout<<"\nYour Initial Balance Was: "<<b;
  73. cout<<"\nYour Total Service Charges Is: ";
  74. cout<<"\nYour End Balance Is: "<<result;
  75. }
  76.  
  77. else
  78. cout<<"Choose A Choice man!";
  79.  
  80.  
  81. }
  82.  
  83. float result(char transaction, float balance, float amount)
  84. {
  85. char t;
  86. float i, b, a;
  87. if (t == 'C')
  88. {
  89. for (i=0;i<1;i++);
  90. {
  91. if ( b < 0 && b < 500)
  92. {
  93. result = b + a - 0.15 - 5;
  94. return result;
  95. }
  96. else if ( b < 500)
  97. {
  98. result = b + a - 5;
  99. return result;
  100. }
  101. else if (b < 0)
  102. {
  103. result = b + a - 0.15;
  104. return result;
  105. }
  106. }
  107. }
  108.  
  109. if (t == 'D')
  110. {
  111. for (i=0;i<1;i++);
  112. {
  113. if ( b < 0 && b < 500)
  114. {
  115. result = b + a - 0.10 - 5;
  116. return;
  117. }
  118. else if ( b < 500)
  119. {
  120. result = b + a - 5;
  121. return;
  122. }
  123. else if (b < 0)
  124. {
  125. result = b + a - 0.10;
  126. return;
  127. }
  128. }
  129. }
  130.  
  131.  
  132. }

For Assignment 4, I have only done the first output. I have no idea on doing the calculation and the final output. >.<
  1. #include <iostream.h>
  2. main()
  3. {
  4. char seat[7][5]= {{'1','A','B','C','D'}, {'3','A','B','C','D'}, {'3','A','B','C','D'}, {'4','A','B','C','D'}, {'5','A','B','C','D'}, {'6','A','B','C','D'}, {'7','A','B','C','D'}};
  5.  
  6. int i,j, sr,
  7. char sc;
  8.  
  9.  
  10. for(i=0;i<7;i++)
  11. {
  12. for(j=0;j<5;j++)
  13.  
  14. cout<<seat[i][j]<<" ";
  15. cout<<"\n";
  16.  
  17. }
  18. cout<<"\nPlease Pick The Seat's Number";
  19. cin>>sr;
  20. cout<<"\nPlease Pick The Seat's Place";
  21. cin>>sc;
  22. return 0;
  23. }

Any kind of help on any kind of assignments are really appreciated..
Assignment 4 - Line 1 should be int main () . Same with the other assignments.

Regarding your indentation, it's a bit off and therefore hard to read. If you've done so, don't mic tabs and spaces because it looks terrible on Daniweb (a tab is 8 spaces). Blocks of code should stand out. Too much or too little indentation makes it hard to read.

Finally, four different assignments should probably be four different threads.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC