Dev-Spot Developer Forums
September 05, 2010, 02:14:59 PM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: Welcome to the LearnCpp.com forums!  Enjoy your stay.
 
   Home   Help Search Login Register  
Pages: 1 2 [3]
  Print  
Author Topic: Principles of Programming College Course - Beginner programs  (Read 5166 times)
swilke
Newbie
*
Posts: 3


View Profile
« Reply #30 on: March 06, 2009, 05:04:31 PM »

hey the sight is back up Dave...
Logged
swilke
Newbie
*
Posts: 3


View Profile
« Reply #31 on: March 06, 2009, 05:08:36 PM »

2/16/09-Class 5-CSUC- Chapter 8, hw#6,project 8-1 and 8-2 separately.

Stuck on this one...

#include <iostream>
// write a program name,address,city,state,zip code
int main()
{
    using namespace std;
   
    string name;
    string address;
    string city;
    string state;
    string zipCode;
   
   
    cout << "What is your name? " << endl;
    getline(cin, name);
   
    cout << "What is your address? " << endl;
    getline(cin, address);
   
    cout << "What is your city? " << endl;
    getline(cin, city);
   
    cout << "What is your state? " << endl;
    getline(cin, state);
   
    cout << "What is your zip code? " << endl;
    getline(cin, zipCode);
   
   
   
    cout << name << endl;
    cout << address << endl;
    cout << city << ", " << state << ", " << zipCode << endl;
   

    system("pause");
    return 0;   
}
Logged
swilke
Newbie
*
Posts: 3


View Profile
« Reply #32 on: March 06, 2009, 05:22:57 PM »

//scott wilke 3-06-09

#include <iostream>
#include <string> 
#include <fstream>
#include <iomanip>
using namespace std;

int main ()
{
  string first;   //used to store user inputted data ( name )
  string address; //used to store user inputted data (  address )
  string city; //used to store user inputted data (  city )
  string state; //used to store user inputted data ( state )
  string zipcode; //used to store user inputted data ( zipcode )
  string phonenumber; //used to store user inputted data ( phone number )
  ofstream outfile;
 
 
 
  //asks for the user to input their name and then records it into a string.
  cout << "your name? ";
  getline (cin, first);     
  //asks for the user to input their address and then records it into a string. 
  cout << "So " << first <<"your address?";
  getline (cin, address);       
  //asks for the user to input their city and then records it into a string. 
  cout << "Really " << address << "? what city is that in?";
  getline(cin, city);   
  //asks for the user to input their state and then records it into a string. 
  cout << "Hmmm I forget, what state is " << city << " in again?";
  getline(cin, state);   
  //asks for the user to input their zipcode and then records it into a string. 
  cout << "zipcode "<< state << "?";
  getline(cin, zipcode);   
  cout << "Wow, " << zipcode << ", who would have guessed, it is 555 here!" << endl;
  cout << "Okay, Okay " << first << " I will stop bugging you, but before I go" << endl;
 
  //asks for the user to input their phone number and then records it into a string.
 
  cout << "what is your phone number?";
  getline(cin, phonenumber);   
  cout << "Awesome! its " << phonenumber << ", mine is 555-5555, Bye!" << endl;
  cout << " " << endl;
  cout << " " << endl;
  cout << " " << endl;
 
  cout << " " << endl;
  cout << " " << endl;
  cout << " " << endl;
  cout << "" << first << endl;
  cout << "" << address << endl;
  cout << "" << city << ", " << state << ", " << zipcode << endl;
  cout << "" << phonenumber << endl;
  cout << " " << endl;
  cout << " " << endl;
  cout << " " << endl;
 
 
  cout << "" << endl;
  cout << "" << endl;
  cout << "" << endl;
  cout << "" << endl;
  system("PAUSE");
  ofstream myfile;
  //make a file containing all information in the strings in a seperate file.
 
  outfile.open ("UsersInformation.txt",ios::out);
  outfile << "The users information is as follows:" << endl;
  outfile << "" << endl; 
  outfile << "User Name: " << first << "" << endl;
  outfile << "User's Address: " << address << "" << endl;
  outfile << "User's City: " << city << "" << endl;
  outfile << "User's State: " << state << "" << endl;
  outfile << "User's Zip Code: " << zipcode << "" << endl;
  outfile << "User's Phone Number: " << phonenumber << "" << endl;
  outfile.close();   
  return 0;
  cin.ignore(100);
   system("PAUSE");
  return 0;
}

Logged
Theo
Global Moderator
Hero Member
*****
Posts: 520



View Profile
« Reply #33 on: March 07, 2009, 02:22:46 AM »

eh...? You are clearly not following instructions given  Tongue You are doing something that I cannot understand even tho the program there is supposed to be easy
Logged

I will not give up on learning C++!!!
-_-.. Allegro vs SDL?
davelucas
Newbie
*
Posts: 23


View Profile
« Reply #34 on: March 07, 2009, 01:06:58 PM »

Scott, I'm on it. Check back in a few.
Logged
dlmorrison
Newbie
*
Posts: 2


View Profile
« Reply #35 on: December 08, 2009, 11:31:09 PM »

thanks alot, it is a real help dave
Logged
B00336730
Newbie
*
Posts: 1


View Profile
« Reply #36 on: February 08, 2010, 01:01:16 PM »

Can Someone help me with the homework assignment 5-7 pg 135 in CSUC?? I am stuck!!
Logged
gorevela
Newbie
*
Posts: 1


View Profile
« Reply #37 on: February 08, 2010, 03:41:22 PM »

Project 3-4
The volume of a box is calculated using the formula V = abc, where a, b, and c are the lengths of the box's sides. Write a program that calculates the volume of a box based on the input of the length of three sides by the user. Save the source code file as volbox.cpp. Compile, run, and test the program.

Edit: Code is attached!

about that you enter the 3 values and it just shuts you out this is how i coded it

//volbox.cpp
//Program to calculate the volume of a box based on 3 sides.
//by, Jonathon Prete

#include<iostream>
using std::cout;
using std::cin;

int main()
{
    float a,b,c,V;
   
    cout<<"enter the lengths of three sides of the box (A,B,and C)\n";
    cout<<"\nWhat is the length of side A?:";
    cin>>a;
    cout<<"\nWhat is the length of side B?:";
    cin>>b;
    cout<<"\nWhat is the length of side C?:";
    cin>>c;
   
    V=a*b*c;
   
    cout<<"\nThe volume of the box is: " <<V<< ".";
    system("pause");
    return 0;

}
   


edit: not sure if its just this computer or program running the c++ but its also happens with your quadratic calculator i enter the 3 values and then it just shuts down the program instead of giving me the answer
« Last Edit: February 08, 2010, 03:55:08 PM by gorevela » Logged
Theo
Global Moderator
Hero Member
*****
Posts: 520



View Profile
« Reply #38 on: February 09, 2010, 05:22:19 AM »

If system("PAUSE") doesn't work, you might want to try cin.get ()

Cheers,
Theo
Logged

I will not give up on learning C++!!!
-_-.. Allegro vs SDL?
JS
Newbie
*
Posts: 1


View Profile
« Reply #39 on: March 12, 2010, 11:21:19 AM »

I had a go at the volume calculator problem, this was my solution.  If there is a better way to do this please let me know, I've only been learning for a week or so.  Thanks for providing a great forum, pardon if this isn't much of a first post Smiley.

-Josh

Source attached below

Code:
#include <iostream>

using namespace std;

int readnumber()
{
 cout << "Insert side length: ";
 int x;
 cin >> x;
 return x;
 }

int writeanswer(int x)
{
    cout << "The volume of your cube is: " << x << endl;
}

int main()
{
    cout << "Volume Calculator" << endl;
    int x = readnumber();
    int y = readnumber();
    int z = readnumber();
    writeanswer (x*y*z);
    return 0;
}
« Last Edit: March 12, 2010, 11:26:29 AM by JS » Logged
laserlight
Global Moderator
Sr. Member
*****
Posts: 430


View Profile
« Reply #40 on: March 12, 2010, 11:27:12 AM »

It looks okay to me Smiley
Logged

Bazaar rocks for distributed version control!
Theo
Global Moderator
Hero Member
*****
Posts: 520



View Profile
« Reply #41 on: March 15, 2010, 06:21:46 AM »

Although it's not really necessary but I suppose you could turn readnumber () into an inline function Cheesy
Logged

I will not give up on learning C++!!!
-_-.. Allegro vs SDL?
darkowner94
Newbie
*
Posts: 1


C++ Intermediate


View Profile
« Reply #42 on: June 22, 2010, 07:27:18 PM »

hey nice tutorials Smiley . Those are helping me for my path to a c++ Programmer ^.^
Logged
Pages: 1 2 [3]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!