Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,152,161 members, 7,815,055 topics. Date: Thursday, 02 May 2024 at 06:09 AM

Please Need Help With Writing These C++ Programmes Please This Is Really Urgent - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / Please Need Help With Writing These C++ Programmes Please This Is Really Urgent (3247 Views)

Who Can Help With Writing An Encryption Algorithm? How Soon Can One Learn How To / I Want To Be A Programmes / Please Need To Know The Open Source Used For Hi5 And Facebook (2) (3) (4)

(1) (Reply) (Go Down)

Please Need Help With Writing These C++ Programmes Please This Is Really Urgent by naija4laif: 2:54am On Mar 14, 2007
The Greatest Common Divisor (GCD) of two positive integers is the largest integer

which can be divided evenly into both integers.

Problem 1: Given two integers A and B (assume that A > B) write a C program that
calls a function called primitiveGCD( A,B) to calculate the GCD of two positive
integers. This function uses a simple algorithm based on successive test of all
numbers less of equal B to find the greatest common divisor.
The pseudo-algorithm for implementing the function is as follows:
1. Require that A ≥ 0 and B ≥ 0
2. If A < B swap A and B
3. Set g = B
4. While g does not simultaneously divide A and B let g=g-1
5. Return g

Problem 2:
Euclide’s algorithm for calculating the GCD of two positive integers is based on the
following observation:
Given two nonnegative integers A and B where (A > B), then
the greatest common divisor of A and B is also the common
divisor of A%B and B.
Write a C program that calls a function EuclideGCD(A,B) that implements Euclid’s
algorithm
Which algorithm is more efficient? Count the number of arithmetic operations used
by each algorithm.
Check the your programs with the following data
A=259 B=111
A=1035 B=55
Re: Please Need Help With Writing These C++ Programmes Please This Is Really Urgent by kino: 6:32pm On Mar 15, 2007
Here is a java solution for EUCLIDE's - it is a recursive function enjoy grin grin grin grin grin
class GCD {

public int gcd(int m, int n) {

if (m < n) {
int t = m;
m = n;
n = t;
}

int r = m % n;

if (r == 0) {
return n;
} else {
return gcd(n, r);
}

}

};
Re: Please Need Help With Writing These C++ Programmes Please This Is Really Urgent by labiran(m): 5:11pm On Oct 26, 2007
can somebody help me write this:



Overview
Using the previous labs on C++ classes as examples, you will now write a class from scratch. Your class will be a 'Person' object and, like other classes, will have data members and member functions. Your class will have at least two constructors. It will also have accessor functions for each of the required data members. Additionally, the class you create must have a validate() function.

After the class has been written, you will use the class and instantiate a 'Person' by reading from a database file. After reading in each person, you will validate the 'Person' instantiated by assuring the data members have 'reasonable' values. Some of the values in the database will be 'unreasonable' and it is your task to sort each 'Person' instantiated into a file called 'valid.txt' and 'invalid.txt'. You are not allowed to alter the values of the original data file.

To get started, create a new empty Win32 Console Application project. Call the project Person Project, and the solution Lab09. Then click on Add Class in the Project menu and select C++ (in the left panel) and C++ Class (in the right panel). Enter the name of your new class: Person. Be sure to deselect all other options in the dialog box.

Preprocessor directives
Be sure to include all the preprocessor directives that your Person class will use. Preprocessor directives could be libraries, namespaces, #defines, etc. For example, you probably want to include the string class: #include <string>

Constructors
You are required to write a default constructor and a constructor that takes two parameters: first name and last name. You may write more constructors, if desired.

Data Members
The required data members are listed below. When declaring your data members, consider the range of possible values (and reasonable values) each data member can have. Doing so will help you choose the correct data type for that data member. (Using appropriate data types is an important part of memory management.)
Your class is required to have the following data members (their required ranges are listed as well, all data ranges are inclusive):

first name: any length string of characters
last name: any length string of characters
age: 0 through 115 (years)
gpa: 0.0 through 4.0
gender: M or F
height: 30.0 through 230.5 (cm)
You may include other data members, but these are required. Be sure that any other data members, and their requisite accessor functions, do not interfere with the requirements of the assignment.
Accessor Functions
You are required to have accessor functions for each of the above data members. Accessor functions, also called 'setters' and 'getters', either gets (returns) or sets a value associated with an object of the class.

Member Functions
You are required to have a function named 'validate' that returns a boolean and takes no parameters. This function, and any other function that makes no changes to the class data members, should be declared as 'const'. This function determines whether a given instance of a 'Person' is valid or invalid. An instance of a 'Person' is considered valid if all of its data values are within the given ranges. Data Members for first name and last name do not need to be validated.

You are encouraged to write other member functions that demonstrate your knowledge; these functions must not break the rest of your code!



Test Program
When writing a class, it is important to verify that your code meets the provided requirements, as well as any pre-conditions and post-conditions. To do this, after your class is written, you must write a program that tests each of your constructors, the end-points of each of the data members, each of the accessor functions, and any other member functions that you have included.

A good way to test a class is to instantiate several objects of that type using each of the constructors, then use all the accessors to return and set the data members. After this, the member functions can be tested by calling them with a range of values from the instantiated objects, particularly any relevant end-points. If there is any unexpected behavior, your class might have an error.

You will now write such a test program. We have provided some code for you to make this task easier: PersonTestExample.cpp (place this file into your Person project folder, along side your class header and source file). Our example code declares and opens files for you. If you have forgotten how to read or write data from a file stream object, refer back to Lab 5.

Using the provided database file, PersonFile.txt, you will read-in each line of data and instantiate a 'Person' with that data. Save this file into your Lab09/PersonClass directory. Each 'Person' object should then be 'validated' using the member function 'validate()'. If a particular object is valid, you will output all of the data members for that 'Person' object into a file called 'valid.txt'. If a particular object is invalid, you will output all of the data members for that 'Person' object to a file named 'invalid.txt'. You must provide these files as part of your .zip file submission (e.g., check that they are in your Lab09/PersonClass directory).

The format of the database file is as follows:
Each line of the file contains information for one person. This information is always in the following order:
lastname firstname age gpa gender height
These items are separated by spaces, i.e., there is one space character between each of the values, nothing else.

Hint: The Time class had you answer four bold questions to help organize your design. We encourage you to write down the answers to each of these questions again, this time for the Person class.

Hint: Design your algorithm BEFORE you begin coding.


Hint: Practice proper data encapsulation by using the 'public' and 'private' keywords appropriately.
Re: Please Need Help With Writing These C++ Programmes Please This Is Really Urgent by Kobojunkie: 6:02pm On Oct 26, 2007
This is really simple @Labiran. If since March, you have not learned how to do this, I suggest you actually Start to READ YOUR BOOK
Re: Please Need Help With Writing These C++ Programmes Please This Is Really Urgent by labiran(m): 4:00am On Oct 27, 2007
@Kobojunkie,

can u pls tell me how to do it becuz i do read the book and still dont understand it. thank
Re: Please Need Help With Writing These C++ Programmes Please This Is Really Urgent by Kobojunkie: 4:14am On Oct 27, 2007
http://www.codersource.net/cpp_tutorial_class.html


http://www.intap.net/~drw/cpp/cpp07_01.htm

Please spend time reading these, even if you have to use a dictionary, use it. If you want, I can even send you videos to help you learn it.

VIDEO Tutorials
=============

http://www.softwaretrainingtutorials.com/c-plus-plus.php

http://www.fafiles.com/cpp_index.php
Re: Please Need Help With Writing These C++ Programmes Please This Is Really Urgent by labiran(m): 7:54pm On Oct 27, 2007
@ Kobojunkie,

thanks for the reading material. i tried to complete the program with it but it still doesn't work. i must be one of the worst programmers ever.
Re: Please Need Help With Writing These C++ Programmes Please This Is Really Urgent by Kobojunkie: 8:02pm On Oct 27, 2007
well, your choice
Re: Please Need Help With Writing These C++ Programmes Please This Is Really Urgent by labiran(m): 8:12pm On Oct 27, 2007
is it possible for me to show you my code? maybe you can tell what is wrong with it.
Re: Please Need Help With Writing These C++ Programmes Please This Is Really Urgent by Kobojunkie: 2:28am On Oct 28, 2007
Best for you since you have seen those videos and read those tutorials and still do not know how to code this, you may need to join c++ forums where even the people there require that you do your work and if you have an error that you are dealing with, you can post your question with the code you are having problems with and they can better help that way but if you are looking for someone to help you write your code, I suggest you instead take a semester off from school and take time to learn how to write basic code, get the concept and then when you get back, you have a better idea of what exactly it is you are dealing with
Re: Please Need Help With Writing These C++ Programmes Please This Is Really Urgent by labiran(m): 9:01pm On Oct 28, 2007
@ Kobojunkie, thank u for the advice
Re: Please Need Help With Writing These C++ Programmes Please This Is Really Urgent by Bossman(m): 5:53pm On Oct 29, 2007
Very good advice from kobojunkie.

The real world is brutal! And you will be tested, at least in the western world. If you do not perfom, they will get rid of you quickly. So, as mentioned, make sure you do what you can to solve this simple problem yourself. For some of us, programming comes natural. I also understand that some of us have to work a bit harder for the concepts to sink.


Good luck to you.
Re: Please Need Help With Writing These C++ Programmes Please This Is Really Urgent by labiran(m): 11:38pm On Oct 29, 2007
anyone think they can get me started? i learn by trial and error
Re: Please Need Help With Writing These C++ Programmes Please This Is Really Urgent by tomX1(m): 9:45am On Oct 31, 2007
@labiran
Sam's Teach Yourself C++ in 21 days and Sam's Teach Yourself Visual C++ 6.0 in 21 Days are very good materials for beginers to intermidiate level programmers.

Programming will require a lot of visualisation, you need to be able to mentaly step into the problem as if its a room then decide how to solve it. It's all in the head.

With reference to one of your previous post on a different thread: Nairaland is not useless. There are people who can and will help you if you will only properly articulate your problem and maybe show some effort in helping yourself. Also don't forget to be courtoues to them. They don't get paid to help you. Appreciate their efforts even if they are unable to give you exactly what you want. They atleast gave you their time.

try to create a thread for your own questions too so that people can easily identify your needs and offer a solution if they have one.

Goodluck and Enjoy.
Re: Please Need Help With Writing These C++ Programmes Please This Is Really Urgent by Kobojunkie: 2:12pm On Oct 31, 2007
Here is the problem with Labiran's post, Your first post on this thread was from back in March. If after you were given the solution for that one, you actually took time to study the subject and learnt it. I see no reason why by now, you can not take information from at least one of those links I gave you and have come up with the answer or something for you to work with so far. For you to come back after the posts I gave you to ask where you need to start from, not only paints you as a very unserious person but also someone who is looking to have others do his/her work and that is not what forums are there to do for you. If you can not spend time on your own to do work, how do you expect to blame people for your own demise??
Re: Please Need Help With Writing These C++ Programmes Please This Is Really Urgent by tboy1(m): 2:41pm On Oct 31, 2007
@tomX:

Sam's Teach Yourself C++ in 21 days and Sam's Teach Yourself Visual C++ 6.0 in 21 Days are very good materials for beginers to intermidiate level programmers.
@labiran
Can you send me ur email, i'll send you the 2 books.
Re: Please Need Help With Writing These C++ Programmes Please This Is Really Urgent by labiran(m): 6:03pm On Nov 01, 2007
@ tboy1,
my email is :

labiran@hotmail.com

@Kobojunkie,
i'm surprised at your level of thoughtlessness.  use your two eyes to read the starter of this thread.  It was not me!  My own started just a few days ago, not all the way back in March.  Who said I was blaming others?  It's like you are reading imaginary lines.  yes, i'm a beginner and did find your websites very helpful (thank you very much!).  it is just I needed like a trial and error experience because programming is hard for me.  I have actually already completed the project bro! thanks
Re: Please Need Help With Writing These C++ Programmes Please This Is Really Urgent by tboy1(m): 6:22pm On Nov 01, 2007
@labiran

I've sent u the 2 books to your email add

.pdf
Re: Please Need Help With Writing These C++ Programmes Please This Is Really Urgent by Kobojunkie: 7:17pm On Nov 01, 2007
I did not notice that you were not the one that started the thread so I apologize for mistaking you for the one who posted back in march.
Re: Please Need Help With Writing These C++ Programmes Please This Is Really Urgent by labiran(m): 7:25pm On Nov 01, 2007
@tboy 1:

thank you so much for your help

@Kobojunkie,
thanks for your help too.
Re: Please Need Help With Writing These C++ Programmes Please This Is Really Urgent by cebili: 3:52pm On Nov 05, 2007
HI N/landers,
i'm new nd know nottin about programmin, hopin to hear 4rm d gurus.


@tboy,
plz kindly send me the books too. i'll appreciate ur effort.

email add. chuksonated77@yahoo.com
Re: Please Need Help With Writing These C++ Programmes Please This Is Really Urgent by tboy1(m): 4:29pm On Nov 08, 2007
@ cebili

I've sent the books to your inbox

Enjoy
Re: Please Need Help With Writing These C++ Programmes Please This Is Really Urgent by Hayorbahmy(m): 8:39pm On Nov 09, 2007
@tboy1
I wont mind the book too pls
my addy is hayorbahmy@gmail.com
Re: Please Need Help With Writing These C++ Programmes Please This Is Really Urgent by tboy1(m): 2:06pm On Nov 12, 2007
@ Hayorbahmy

sent to ur inbox
Re: Please Need Help With Writing These C++ Programmes Please This Is Really Urgent by tonak(m): 5:19pm On Nov 14, 2007
hello tboy1,
im just starting on programming specifically vb.net and ASP.NET, though i bought a book by Dietel, im still having problems.im also interested in c++, i will really appreciate it if you could assist me with some materials especially for a beginner.my email is tonnie23@yahoo.com. expecting your response. tanks
Re: Please Need Help With Writing These C++ Programmes Please This Is Really Urgent by yinka007(m): 11:38am On Nov 15, 2007
Re: Please Need Help With Writing These C++ Programmes Please This Is Really Urgent by tboy1(m): 2:04pm On Nov 15, 2007
@ tonak

Check your inbox, i've sent you all the books you requested.
If you've got any probs while learning, send me a mail.
Re: Please Need Help With Writing These C++ Programmes Please This Is Really Urgent by Dmajesty(m): 3:19pm On Dec 01, 2007
Web designing and programming is becoming the talk of the moment in information and computer technology. People are made to pay heavy amount of money in other to learn how to design and program web pages. You don’t need to be a computer scientist or a guru in computer for you to know how to handle that. I have a self explanatory tutorial that can guide you to learn how to become a web programmer using the most popular, and powerful web programming language called PHP.

As you go through the site, you can search other free links go get more tutorial in other software with little or no fee. http://knowphp.webs.io

Cheers! Share with others.
One Nigeria Forever

(1) (Reply)

A Blogger Asks, Should I Abandon VB.Net? / I Want To Learn Programming. Which Language Should I Start With? / Sachng.com, Better Don Land.

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 54
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.