|
C++ Beginner help
|
|
02-09-2010, 04:53 AM
(This post was last modified: 02-09-2010 05:26 AM by Wheaties.)
Post: #1
|
|||
|
|||
|
C++ Beginner help
This is a story problem I have for homework. I am also writing the code for this I would just like to see if anyone could write the code so I could possibly compare and ask questions.
Teacher's Pet is a software firm that specalizes in children's educational programs. The firm has decided to devolop a series of products that will help children discover the properties of fractions. As you plan the program series, you realize, you realize that a fraction contains at least two data properties: a numerator and a denominator. Therefore you begin to think of specified fractions as objects that belong to the class Fraction. For now though, you decide to work with structs. Develop a Fraction Struct so that it contains public data fields that hold the integers numerator and denominator.(In later chapters you will change your data structure to a class and learn to make these data fields private.) Write a main () function that declares Fraction and allows you to enter data values for the two Fraction fields. Echo the input. Save the file as Fraction.cpp ok so this should be fairly simple, for you guys at least. If you could help me out that would be awesome. Don't laugh, this is what i have so far. Code: #include<iostream> |
|||
|
02-09-2010, 05:02 AM
(This post was last modified: 02-09-2010 05:11 AM by drdebcol.)
Post: #2
|
|||
|
|||
|
RE: C++ Beginner help
You are right, this is not a big problem !
Struct is type of data, you are basically declaring your own type ! So here is the code for declaring, reading and outputting struct that represents fraction : Code: # include <iostream>I almost forgot. I wrote something about fraction operations in Pascal. But you have mathematical explanations there than can be used in C++ too. I suppose that you want to make a whole class of "fraction struct" and to use it in "# include" area. So you can do 4 basic operations with fractions, or even more ! So here is the link : http://www.pro9ramming.com/fraction-oper...t-812.html We attack any new problem we encounter with techniques we already know, and try small modifications if difficulties turn up. Bram Cohen - Bit Torrent Creator |
|||
|
02-09-2010, 05:28 AM
Post: #3
|
|||
|
|||
|
RE: C++ Beginner help
thanks so much dude. Very quick response and I wasn't too far off.
Cheers
|
|||
|
« Next Oldest | Next Newest »
|





