Welcome! Log In Create A New Profile

Advanced

Assignment Problems

Posted by Roshelle 
Announcements Last Post
Announcement SoC Curricula 09/30/2017 01:08PM
Announcement Demarcation or scoping of examinations and assessment 02/13/2017 07:59AM
Announcement School of Computing Short Learning Programmes 11/24/2014 08:37AM
Announcement Unisa contact information 07/28/2011 01:28PM
Assignment Problems
April 06, 2006 12:32PM
Hi Guys

I seem to be having major major problems.I'v been sitting with this assignment for ages and not getting anywhere.Is there anyone in durban that would be willing to assist.Even better,are there any study groups that i could participate in.

Computergeek,where are you from,you seem to know lot about what s happening.Do you mind helping out.

Thanks

Roshelle
Re: Assignment Problems
April 07, 2006 04:18PM
Hi Rochelle

What are u having problems with? I am from Cape Town. Only a email away.

Brendon
Re: Assignment Problems
April 08, 2006 11:46PM
Hi Roshelle...

I have completed the assignment and would be happy to explain and help you out. Where are you having problems ?

Geek of the week
Re: Assignment Problems
April 10, 2006 07:20AM
Ok i am still at question 7.I am only going to submit what i've done.i think the amount of work they expect us to cover in one month is ridiculous..

Thanks for the offer guys

Roshelle
Anonymous User
Re: Assignment Problems
April 12, 2006 12:19PM
Hi BrendonW and ComputerGeek i just thought perhaps you could assist me with Assignment 1 i'm from Cape Town.i know it's already due but i'm going to submit late, coz of circumstances @ work.I'm struggling eith Q6 and Q7 while loops and nested...

Please help.. it will be greatly appreciated!!

Thanx in advance smile
Re: Assignment Problems
April 12, 2006 12:30PM
Question 6a

Error
2 things to consider.
1)What is the length of the first child before and upon entering the while loop?

2)How will the zero length affect our program?

At the moment if the first value entered is zero the program will still execute the while loop and increment number of children to one. It will also increment total length to zero length and then calculate average zero.

Next if the length of child number 1, number 2 and the nth child are entered the compiler will add zero as the nth + 1 number which will always result in 1 more child.

Solution
Before entering the while loop get the first length from the user. So if the user enters zero the while loop will never execute and it will continue to the if statement. The number of children will be incremented only when length is greater than zero, because before entering or incrementing any counters inside the while loop, it will terminate if length is zero.

Initialize total length to the first length entered before the loop. So that it includes the first length upon calculating the sum of the rest of the lengths.

#include <iostream>
using namespace std;

int main() {
int NumChil;
float Len, AveLen, TotLen;

NumChil = 0;
TotLen = 0;

cout << "Please enter the length of first child: ";//Code added
cin >> Len; //Code added
TotLen = Len; //Code added

while (Len > 0) {
cout << "Pease enter next childs Length: ";
cin >> Len;
TotLen += Len;
NumChil++;
}

if (NumChil > 0)
AveLen = TotLen / NumChil;
else
AveLen = 0;

cout << "The average Length is " << AveLen << endl;

return 0;
}


Question 6b

Because SleepTime never gets updated inside the while loop and since SleepTime is the control variable of the while loop the condition is never met and the loop never terminates. Unless –10 ten is entered as the first value the loop will jump into an infinite loop.

#include <iostream>
using namespace std;

int main() {
int NumLess;
float SleepTime;

cout << "Please enter the sleeping time of the first person: ";
cin >> SleepTime;

Numless = 0;

while (SleepTime != -10) {
cout << "Please enter the next persons sleeptime: ";
cin >> SleepTime;
if (SleepTime < 7)
NumLess++;
}
cout << "Number of people sleeping less then 7 hours: " << NumLess << endl;

return 0;
}




























Question 7a

Program

//Number of Biscuits Assignment 1 Question 7a
#include <iostream>
using namespace std;

int main() {
int NumChilBisc, NumPerBisc, NumBisc;
const int NumChil = 63;

//Initialize variables
NumChilBisc = 0;
NumPerBisc = 0;

//Get first input from user
cout << "Enter the first amount donated by the Goody-goody Biscuit Factory: ";
cin >> NumBisc;
cout << endl;

//Calculate first number of biscuits children and personnel get
if (NumBisc > 0) {
NumChilBisc = NumBisc / NumChil;
NumPerBisc = NumBisc % NumChil;
cout << "The number of biscuits each child will get is: " << NumChilBisc << endl;
cout << endl;
cout << "The number of biscuits left fot the personnel is: " << NumPerBisc << endl;
cout << endl;

//Get the rest of the number of biscuits
while (NumBisc > 0) {
cout << "Enter the next amount of Biscuits donated: ";
cin >> NumBisc;
cout << endl;

//Calculate the number of biscuits children and personnel get
if (NumBisc != 0) {
NumChilBisc = NumBisc / NumChil;
NumPerBisc = NumBisc % NumChil;
cout << "The number of biscuits each child will get is: " << NumChilBisc << endl;
cout << endl;
cout << "The number of biscuits left for the personnel is: " << NumPerBisc << endl;
cout << endl;
}
else
cout << "Sorry Goody-goody did not donate any biscuits!! ";
}

}
else
cout << "Sorry Goody-goody did not donate any biscuits!! ";

return 0;
}













Output

Enter the first amount donated by the Goody-goody Biscuit Factory: 113

The number of biscuits each child will get is: 1

The number of biscuits left fot the personnel is: 50

Enter the next amount of Biscuits donated: 152

The number of biscuits each child will get is: 2

The number of biscuits left for the personnel is: 26

Enter the next amount of Biscuits donated: 212

The number of biscuits each child will get is: 3

The number of biscuits left for the personnel is: 23

Enter the next amount of Biscuits donated: 317

The number of biscuits each child will get is: 5

The number of biscuits left for the personnel is: 2

Enter the next amount of Biscuits donated: 19

The number of biscuits each child will get is: 0

The number of biscuits left for the personnel is: 19

Enter the next amount of Biscuits donated: 166

The number of biscuits each child will get is: 2

The number of biscuits left for the personnel is: 40

Enter the next amount of Biscuits donated: 0

Sorry Goody-goody did not donate any biscuits!!

Terminated with return code 0
Press any key to continue ...








Anonymous User
Re: Assignment Problems
April 12, 2006 04:06PM
Thanx alot Brendonw, i'm also from CPT but in da Somerset-West area.Where in CPT are you?May be we could meet sometime and work through certain chapters where i encountered errors.

Thanx a million for you help, i really appreciate it!! smiling smiley
Anonymous User
Re: Assignment Problems
April 13, 2006 08:10AM
Hi there i just want to know could you just give me a guideline or assist me with Question 3 b & 3 C as well as Question 4.Pleassseee...
Re: Assignment Problems
April 13, 2006 09:02AM
Hi 4u2nv

What is your name, do you have an e-mail address?

As to these Questions I am going to give you some guidelines and if you do not come right then I will forward you the answers since this assignment was due already.

The following arrhythmic operators (please familiarize your self with C++ different operators)
+ Addition
- Subtraction
/ Division
* Multiplication
( ) Open and close parenthesis

There are rules that guide the compilation of these operators in C++ notation, in fact these rules apply to all programming languages. If you know these you know them all.

Rules
1. ( ) takes preference over everything (this mean you always do whatever is between parenthesis).
2. Multiplication and division takes preference over addition and subtraction.
3. Between addition and subtraction you do whichever comes first
4. The same between Multiplication and division you do whichever comes first.

Now apply the rules 1 to 4 in calculating the algebraic equation:

y – x / y * 2.0

By using y = 6 and x = 4.

Try to do this and give me a shout.

My details
Brendon
email- Brendonw@lona.co.za
Anonymous User
Re: Assignment Problems
April 13, 2006 10:22AM
My name is Edwina and e-mail address: edwinafrantz@yahoo.com eye popping smiley cool smiley
Re: Assignment Problems
April 13, 2006 11:50AM
anyone in durban......am having a problem with obtainig the prescribed book. Are there any recommende books we can use besides Cohoon and Davidson.
Re: Assignment Problems
April 13, 2006 10:05PM
I was told that its possible to pas COS111 without the text book and to just use the study guide. Dont blame me if it doesnt work for you thoughbut im going to just use the study guide smiling smiley
Re: Assignment Problems
April 18, 2006 11:45AM
I would agree with Computergeek, but for additional material you will have to consult the textbook. You have noticed that COS112 and COS111 are using the same textbook. While you are matering COS111 you are actually also starting on COS112.
Re: Assignment Problems
April 23, 2006 03:44PM
Hi i having problems with running the programs.. every time i run a program.. it gives me an error in the compiler "unable to run program" and in the directory c:/unisa/devcpp/2 { this is where i installed the program } in line 2..

First of all.. what is 2??
Second of all.. how do i change the directory that the compiler is reading from in C++ program itself?

Thirdly Rochelle.. i'm in durban.. You come on sturdays for lectures and tutorials ?

I handed in first assignment but had to do most of it from another computer!!!!!
Help Someone.. second 1 due in 2 weeks..

I know whats happening tho..

Regards..

The Surfa eye rolling smiley

DrOp a LiNe at melish@ravemail.co.za

PleAse SomEoNe HeLP![/img]
Re: Assignment Problems
April 06, 2008 02:13PM
sum1 plz help me with assignment 1 questions(6-20)
received study material very late and didnt have the time 2 do all the lessons
Sorry, only registered users may post in this forum.

Click here to login