Skip to main content

Infection Simulation

0 likes • Nov 18, 2022 • 2 views
C++
Loading...

More C++ Posts

Critques

0 likes • Feb 4, 2021 • 0 views
C++
#include <iostream>
using namespace std;
main
{
cout << "No tabbing. That's very sad :(\n";
cout << "No in-editor highlighting either :(((\n";
cout << "Descriptions might be niice too.";
}

Hello World!

0 likes • Aug 31, 2020 • 2 views
C++
#include <iostream>
using namespace std;
int main() {
cout << "Hello World!\n";
// Prints out "Hello World"
return 0;
}

UNT CSCE 1040 Goat Program

0 likes • Nov 18, 2022 • 1 view
C++
#include "goat.h" //include goat.h
void Goat::setBreed(string breed) {
this->breed = breed;
}
void Goat::setWeight(float weight) {
this->weight = weight;
}
void Goat::setName(string name) {
this->name = name;
}
void Goat::setGender(char gender) {
this->gender = gender;
}
void Goat::setSpayed(bool goatIsSpayed) {
this->goatIsSpayed = goatIsSpayed;
}
void Goat::setRegistrationID(string registrationID) {
this->registrationID = registrationID;
}
void Goat::setColor(string color) {
this->color = color;
}
void Goat::setOtherComments(string otherComments) {
this->otherComments = otherComments;
}
string Goat::getBreed() {
return breed;
}
float Goat::getWeight() {
return weight;
}
string Goat::getName() {
return name;
}
char Goat::getGender() {
return gender;
}
bool Goat::getSpayed() {
return goatIsSpayed;
}
string Goat::getRegistrationID() {
return registrationID;
}
string Goat::getColor() {
return color;
}
string Goat::getOtherComments() {
return otherComments;
}
Goat::Goat() {
breed = "";
weight = 0.0;
name = "";
gender = '\0';
goatIsSpayed = false;
registrationID = "";
color = "";
otherComments = "";
}
Goat::Goat(string goatBreed, float goatWeight, string goatName, char goatGender, bool goatSpayedStatus, string goatRegistrationID, string goatColor, string goatOtherComments) {
breed = goatBreed;
weight = goatWeight;
name = goatName;
gender = goatGender;
goatIsSpayed = goatSpayedStatus;
registrationID = goatRegistrationID;
color = goatColor;
otherComments = goatOtherComments;
}
Goat::~Goat() {
cout << "goat destroyed" << endl;
}
void Goat::printinfo() {
cout << "Breed: " << breed << endl << "weight: " << weight << endl << "Name: " << name << endl << "Gender: " << gender << endl << "is Spayed: ";
if(goatIsSpayed) { //here I do a logical test on boolean goatIsSpayed. if true cout << true else cout << false
cout << "True";
} else {
cout << "False";
}
cout << endl << "Registration ID: " << registrationID << endl << "Color Description: " << color << endl << "Other Comments: " << otherComments << endl << endl;
}

Two Letter Combinations

0 likes • Nov 18, 2022 • 0 views
C++
#include <iostream>
#include <fstream>
#include <string>
#include <cstring>
using namespace std;
//This program makes a new text file that contains all combinations of two letters.
// aa, ab, ..., zy, zz
int main(){
string filename = "two_letters.txt";
ofstream outFile;
outFile.open(filename.c_str());
if(!outFile.is_open()){
cout << "Something's wrong. Closing..." << endl;
return 0;
}
for(char first = 'a'; first <= 'z'; first++){
for(char second = 'a'; second <= 'z'; second++){
outFile << first << second << " ";
}
outFile << endl;
}
return 0;
}

Hello, World!

0 likes • Nov 18, 2022 • 2 views
C++
#include <iostream>
using namespace std;
int main()
{
cout << "Hello, World!" << endl;
return 0;
}

Compute Volume of Cylinder

0 likes • Nov 18, 2022 • 0 views
C++
/*
Algorithm:
Step 1: Get radius of the cylinder from the user and store in variable r
Step 2: Get height of the cylinder from the user and store in variable h
Step 3: Multiply radius * radius * height * pi and store in v
Step 4: Display the volume
*/
#include <iostream>
using namespace std;
int main()
{
float r; //define variable for radius
float h; //define variable for height
float v;
float pi;
pi=3.1416;
cout<<"Enter radius:";
cin>>r;
cout<<"Enter height:";
cin>>h;
v=r*r*h*pi; //compute volume
cout<<"Radius:"<<r<<"\tHeight:"<<h<<endl; //display radius and height
cout<<"\n************************\n";
cout<<"Volume:"<<v<<endl;//display volume
return 0;
}