Ask Experts Questions for FREE Help !
Ask
    babychick2's Avatar
    babychick2 Posts: 44, Reputation: 1
    Junior Member
     
    #1

    Mar 6, 2013, 08:39 AM
    how to write the code?
    can somebody solve this question if was using c++ studio..

    Create an advance data type to represent a Complex Number. A complex number is something which has two parts,
    the real part and an imaginary part. Some example complex numbers are:
    2+3i, -5+7i, -1-2i, and so on. Name this class "Complex". This class should have only two member variables:
    1) real (int type)
    2) imaginary (int type)

    Make all the member variables private. For this class, implement the following:

    1) Constructors (default and overloaded), Getters and Setters.
    2) overload the following operators as friend functions: ==, +, binary -, unary -, <<, >>
    3) Friend function named Multiply which can multiply two complex numbers and return the result complex number
    4) Member function named Multiply which can multiply two complex numbers and return the result complex number
    5) Non-friend Non-member function named NonMemberMultiply which can multiply two complex numbers and return the result
    complex number.

    Note the following points:
    1) the overloaded operator "<<" should print the complex number in the form like this: 2+3i, or -2+4i
    2) also note that, if a complex number has real part 0, then it should be printed like this: 4i. Similarly if it has imaginary part 0, it should be printed just like an integer like this: -2.
    3) Your code must be Efficient (call-by-reference) and Secure (const) as much as possible.
    4) note that multiplying two complex numbers, for example 2-3i and -4+5i works like this:
    (2-3i) * (-4+5i) = 2*(-4+5i) -3i*(-4+5i)
    = -8+10i + 12i -15(I*i)
    = -8+10i + 12i -15(-1)
    = -8+10i + 12i +15
    = 7+22i
    babychick2's Avatar
    babychick2 Posts: 44, Reputation: 1
    Junior Member
     
    #2

    Apr 15, 2013, 09:41 AM
    ?? //
    Create a class to represent student. This class should contain the following public members:

    1) ID: int
    2) FirstName: string
    3) College: string
    4) Major: string
    5) GPA: double
    6) Friends: Student *
    7) next: Student *

    Implement the following for this class:

    1) Default and Overloaded constructors.
    2) Write a function "void CreateList(Node * & h)" which will create a linked list of couple of students (say 5 students) and for each student this function will add a number of friends as another linked list.
    3) Write a Print function to print the entire linked list as mentioned in the project file.
    4) Write a function "bool FindFriendship(3, 6)" which will return true if student with id=6 is a friend of student with id=3. Otherwise it will return false.
    5) Write main() where you will call CreateList(), Print() and FindFriendship() functions to check their working.
    JudyKayTee's Avatar
    JudyKayTee Posts: 46,503, Reputation: 4600
    Uber Member
     
    #3

    Apr 15, 2013, 09:43 AM
    It's against AMHD policy to do homework.

    - this is a particularly lengthy and complicated problem, which you have copied.

    I'm sure your textbook has the answers.
    babychick2's Avatar
    babychick2 Posts: 44, Reputation: 1
    Junior Member
     
    #4

    Apr 15, 2013, 10:01 AM
    help me answer this
    Create a class to represent student. This class should contain the following public members:

    1) ID: int
    2) FirstName: string
    3) College: string
    4) Major: string
    5) GPA: double
    6) Friends: Student *
    7) next: Student *

    Implement the following for this class:

    1) Default and Overloaded constructors.
    2) Write a function "void CreateList(Node * & h)" which will create a linked list of couple of students (say 5 students) and for each student this function will add a number of friends as another linked list.
    3) Write a Print function to print the entire linked list as mentioned in the project file.
    4) Write a function "bool FindFriendship(3, 6)" which will return true if student with id=6 is a friend of student with id=3. Otherwise it will return false.
    5) Write main() where you will call CreateList(), Print() and FindFriendship() functions to check their working.
    Curlyben's Avatar
    Curlyben Posts: 18,514, Reputation: 1860
    BossMan
     
    #5

    Apr 15, 2013, 10:10 AM
    What do YOU think ?
    While we're happy to HELP we won't do all the work for you.
    Show us what you have done and where you are having problems..
    babychick2's Avatar
    babychick2 Posts: 44, Reputation: 1
    Junior Member
     
    #6

    Apr 15, 2013, 12:18 PM
    this is what I did and it is showing errors. Please correct the mistakes
    #include <iostream>
    #include <string>
    using namespace std;

    class Student
    {
    public:
    int ID;
    string FirstName;
    string College;
    string Major;
    double GPA;
    Student*Friends;
    Student*next;
    Student();
    Student(int id1, string FirstName1, string College1, string Major1, double GPA1);
    CreateList(Node*& head, int n)

    bool FindFriendship(int a, int b);
    };

    Student::Student()
    {
    int ID=0;
    string FirstName=" ';
    string College=' ';
    string Major=' ';
    double GPA=0;
    friends=NULL;
    next=NULL;

    }

    Student::Student(int id1, string FirstName1, string College1, string Major1, double GPA1)
    {
    int id=id1;
    string FirstName='FirstName1';
    string College='College1';
    string Major='Major1';
    double GPA=GPA1;
    }

    void Student::CreateList(Student *&h, int n)
    {
    void Create(Node*& head, int n)
    {
    AddHead(h, "Sara", 1, "College of computer engineering and science", "Information Technology", 3.25);
    AddHead(h, "Hiba", 2, "College of Engineering", "Interior Design", 2.7);
    AddHead(h, "Lujain", 3, "College of Business Administration", "MIS", 3.01);
    AddHead(h, "Amna", 4, "College of Arts and Sciences", "Law", 3.68);
    AddHead(h, "Nasreen", 5, "College of computer engineering and science", "Computer Science", 3.44);

    Student*a=new Student("Sara", 1, "College of computer engineering and science", "Information Technology", 3.25);
    Addtail(a, "Nasreen", 5, "College of computer engineering and science", "Computer Science", 3.44);
    Addtail(a, "Lujain", 3, "College of Business Administration", "MIS", 3.01);
    Addtail(a, "Amna", 4, "College of Arts and Sciences", "Law", 3.68);

    Student*b=new Student("Hiba", 2, "College of Engineering", "Interior Design", 2.7);
    Addtail(b, "Nasreen", 5, "College of computer engineering and science", "Computer Science", 3.44);

    Student*c=new Student("Lujain", 3, "College of Business Administration", "MIS", 3.01);
    Addtail (c, "Sara", 1, "College of computer engineering and science", "Information Technology", 3.25);
    Addtail (c, "Amna", 4, "College of Arts and Sciences", "Law", 3.68);

    Student*d=new Student("Amna", 4, "College of Arts and Sciences", "Law", 3.68);
    Addtail (d,"Hiba", 2, "College of Engineering", "Interior Design", 2.7);

    Student*e=new Student("Nasreen", 5, "College of computer engineering and science", "Computer Science", 3.44);
    Addtail (e, "Lujain", 3, "College of Business Administration", "MIS", 3.01);

    }

    void Print(student* h)
    {
    while(h)
    {
    cout<<h->id;
    cout<<h->firstname
    cout<<h->college;
    cout<<h->GPA;
    cout<<h->major;
    h=h->next;
    }
    cout<<endl;

    int main()
    {
    student*head=NULL;
    head->next=(
    print (head);
    createlist(head,5);
    return 0;
    }
    Quote Originally Posted by Curlyben View Post
    What do YOU think ?
    While we're happy to HELP we wont do all the work for you.
    Show us what you have done and where you are having problems..
    ScottGem's Avatar
    ScottGem Posts: 64,966, Reputation: 6056
    Computer Expert and Renaissance Man
     
    #7

    Apr 15, 2013, 12:21 PM
    What errors and where?

Not your question? Ask your question View similar questions

 

Question Tools Search this Question
Search this Question:

Advanced Search

Add your answer here.


Check out some similar questions!

Design an interface for calculator and write code. [ 0 Answers ]

Design an interface for calculator and write code.

Write basic Pseudo code If-t [ 3 Answers ]

WRITE the basic pseudo code IF-THEN-ELSE statement for each of the following:   1. If sum is greater than 100, print sum. 2. If sum is greater than 5, print sum else add 10 to sum. 3. If grade is greater than or equal to 90, print “A” else if grade is greater than or equal 80, print “B”,...

Write pseudo code reads in course information that includes class code, three digit s [ 1 Answers ]

Design a flowchart or pseudocode for a program that accepts rental contract data and displays a completed rental contract ready for a customer’s signature. Accept the following as input: Contract number Customer’s first and last names Automobile’s vehicle identification number Starting date...


View more questions Search