C++ Assignment 4.1 & 4.7
Moderators: vinyard, KreepingMonkey
Re: C++ Assignment 4.1
Ok so i finally got it, after 2 fucking days. Well here are my results
Now this is 4.7...finally finished it
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;
}
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
Reason: corrected the grades and added 4.7
