C++ Assignment 4.1 & 4.7

Moderators: vinyard, KreepingMonkey

Message
Author
User avatar
zero86ea
C.S. Server Admin
Posts: 318
Joined: Tue Jun 19, 2007 12:02 am
Contact:

Re: C++ Assignment 4.1

#11 Post by zero86ea » Sun Sep 30, 2007 2:05 am

you better fix them! it looks ugly w/ the comments like that!
Image

User avatar
zero86ea
C.S. Server Admin
Posts: 318
Joined: Tue Jun 19, 2007 12:02 am
Contact:

Re: C++ Assignment 4.1

#12 Post by zero86ea » Mon Oct 01, 2007 1:33 pm

Ok so i finally got it, after 2 fucking days. Well here are my results :)

Code: Select all

/***************************************************************************************************************
/*Programmer: Efren Arrieta*************************************************************************************
/*Class     : Co Sci 440 C++************************************************************************************ 
/*Excercise : Excercise 4.1 Page********************************************************************************
***************************************************************************************************************/

#include <iostream>
#include <cstdlib>                                          
#include <cstring>                                          //Add string library

using namespace std;

int main()                                                  //This is the main function
{                                                    
    char firstName[25];                                     //First and middle name
    char lastName[25];                                      //Last name
    int age;												//Age
    char grade;                                             //Grade deserved
                                                            
    
    cout << "What is your first name?";                     //Shows First and middle name
    cin.get(firstName, 25).get();                           //Enter first name
    cout << "What is your last name?";                      //Shows last name
    cin.get(lastName, 25).get();                                        //Enter last name
    cout << "What letter grade do you deserve?";            //Shows grade deserved
    cin >> grade;                                           //Enter grade deserved
    cout << "What is your age?";                            //Shows age
    cin >> age;                                             //Enter age
	
	cout << "Name: " << lastName << ", " << firstName;      //Displays last name first, then first and middle name
    cout << endl;										
    if (grade == 'A' || grade == 'a')						//If grade entered is A, then grade should be B
		cout << "Grade: B" << endl;							
	else if (grade == 'B' || grade == 'b')					//If grade entered is B, then grade should be C
		cout << "Grade: C" << endl;
	else if (grade == 'C' || grade == 'c')					//If grade entered is C, then grade should be F
		cout << "Grade: D" << endl;
	else cout << "Grade: F" << endl;
	cout << "Age: " << age;                                 //Displays final age
    cout << endl;

	
    system("pause");                                        
    return 0;
}

Now this is 4.7...finally finished it :D

Code: Select all

/***************************************************************************************************************
/*Programmer: Efren Arrieta*************************************************************************************
/*Class     : Co Sci 440 C++************************************************************************************ 
/*Excercise : Excercise 4.7 Page********************************************************************************
***************************************************************************************************************/

#include <iostream>
#include <cstdlib>
#include <cstring>

using namespace std;

struct company
{
	char companyName[30];
	double pizzaDiameter;
	double pizzaWeight;
};

int main()
{
	company companyOne;
	
	cout << "Enter the Pizza Company name:";
	cin.get(companyOne.companyName, 30);
	cout << "Enter the diameter of the pizza in inches:";
	cin >> companyOne.pizzaDiameter;
	cout << "Enter the weight of the pizza in ounces:";
	cin >> companyOne.pizzaWeight;

	cout << "Company Name: " << companyOne.companyName;
	cout << endl;
	cout << "Pizza diameter in inches: " << companyOne.pizzaDiameter;
	cout << endl;
	cout << "Pizza weight in ounces: " << companyOne.pizzaWeight;
	cout << endl;

	system("PAUSE");

	return 0;
}
Last edited by zero86ea on Mon Oct 01, 2007 9:29 pm, edited 2 times in total.
Reason: corrected the grades and added 4.7
Image

Post Reply