1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Help stuck

Discussion in 'C++' started by icechef, Feb 21, 2009.

  1. icechef

    icechef New Member

    Joined:
    Feb 21, 2009
    Messages:
    10
    Likes Received:
    0
    Trophy Points:
    0
    Hi
    Im trying to write a program that allows me to enter relevant infomation(shows on programme).
    But now im stuck I want the user to be able to put there own info as many times as they state and then be able to display it.
    Any help appreciated?
    Thanks
    Code:
    [SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]#include[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"stdafx.h"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]//
    [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]#include[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]<iostream.>[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]//
    [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]#include[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]<string.h>[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]//
    [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]#include[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]<sstream>
    [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]using[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]namespace[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] std; [/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]//
    //------------------------------------------------------------------
    [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]
    [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]class[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] MB [/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// Setting for creating Motherboard class.
    [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]{
    [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]public[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]: [/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// Constructors Public.
    [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]MB([/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]char[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] * , [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]long[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]float[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]); [/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// Define programs parameters.
    [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]void[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] show_MB([/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]void[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]); [/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// 
    [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]private[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]: [/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// Constructors private.
    [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]char[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] MBP [25]; [/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// Required specification.
    [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]long[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] MBM; [/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// Required specification.
    [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]float[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] MBR; [/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// Required specification.
    [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]};
    [/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]//-------------------------------------------------------------------------
    [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]MB::MB([/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]char[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] * MBP, [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]long[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] MBM, [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]float[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] MBR) [/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// Order of sequence.
    //-------------------------------------------------------------------------
    [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]{
    strcpy(MB::MBP, MBP); [/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// Relates to program within.
    [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]MB::MBM = MBM; [/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// Relates to program within.
    [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]MB::MBR = MBR; [/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// Relates to program within.
    [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]};
    [/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]//-------------------------------------------------------------------
    [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]void[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] MB::show_MB([/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]void[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]) 
    {
    cout << [/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"Processor: "[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] << MBP << endl; [/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// Display.
    [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]cout << [/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"Speed: "[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] << MBM << [/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]" Mhz "[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] << endl; [/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// Display.
    [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]cout << [/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"RAM: "[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] << MBR << [/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]" GB "[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] << endl; [/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// Display.
    [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]};
    [/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]//--------------------------------------------------------------------------------
    [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]class[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] VC [/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// Setting for creating Video Card class.
    [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]{
    [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]public[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]: [/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// Constructors Public.
    [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]VC([/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]char[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] *, [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]int[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]int[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]float[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]); [/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// Define programs parameters.
    [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]void[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] show_VC([/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]void[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]); [/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]//
    [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]private[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]: [/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// Constructors private.
    [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]char[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] VCB [25]; [/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// Required specification.
    [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]int[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] VCX; [/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// Required specification.
    [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]int[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] VCY; [/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// Required specification.
    [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]float[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] VCM; [/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// Required specification.
    [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]};
    [/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]//------------------------------------------------------------------------------
    [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]VC::VC([/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]char[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] * VCB, [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]int[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] VCX, [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]int[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] VCY, [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]float[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] VCM) [/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// Order of sequence.
    //-----------------------------------------------------------------------------
    [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]{
    strcpy(VC::VCB, VCB); [/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// Relates to program within.
    [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]VC::VCX = VCX; [/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// Relates to program within.
    [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]VC::VCY = VCY; [/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// Relates to program within.
    [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]VC::VCM = VCM; [/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// Relates to program within.
    [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]};
    [/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]//-------------------------------------------------------------------------------
    [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]void[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] VC::show_VC([/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]void[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2])
    {
    cout << [/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"Brand: "[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] << VCB << endl; [/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// Display.
    [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]cout << [/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"Display: "[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] <<VCX<< [/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]" X "[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] <<VCY<< endl; [/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// Display.
    [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]cout << [/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"RAM: "[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] << VCM << [/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]" GB "[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] << endl; [/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// Display.
    [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]};
     
    [/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]//--------------------------------------------------------------------------------
    [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]class[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] COMPUTER : [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]public[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] MB, [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]public[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] VC [/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// Setting for creating Computer class.
    [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]{
    [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]public[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]: [/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// Constructors Public.
    [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]COMPUTER([/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]char[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] *, [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]int[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]float[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]char[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] *, [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]long[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]float[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]char[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] *, [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]int[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]int[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]float[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]); [/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// Define programs parameters.
    [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]void[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] show_COMPUTER([/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]void[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]);
    [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]private[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]:
    [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]char[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] B[25]; [/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// Required specification.
    [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]int[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] HD; [/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// Required specification.
    [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]float[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] P; [/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// Required specification.
    [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]};
    [/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]//-----------------------------------------------------------------------------------------------
    [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]COMPUTER::COMPUTER([/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]char[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] * B, [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]int[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] HD, [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]float[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] P, [/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// A parameters.
    [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]char[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] * MBP,[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]long[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] MBM, [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]float[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] MBR, [/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// MB parameters.
    [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]char[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] * VCB, [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]int[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] VCX, [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]int[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] VCY, [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]float[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] VCM) [/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// VC parameters.
    [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]: MB(MBP, MBM, MBR ), VC(VCB, VCX, VCY, VCM ) [/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// Within A Parameters.
    //-------------------------------------------------------------------------------------------------
    [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]{
    strcpy(COMPUTER::B, B); [/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// Relates to program within.
    [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]COMPUTER::HD = HD; [/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// Relates to program within.
    [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]COMPUTER::P = P; [/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// Relates to program within.
    [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]MB (MBP,MBM,MBR); [/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// Relates to program within.
    [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]VC (VCB,VCX,VCY,VCM); [/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// Relates to program within.
    [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]}
    [/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]//----------------------------------------------------------------------------------------
    [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]void[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] COMPUTER::show_COMPUTER([/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]void[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2])
    {
    cout << [/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"Brand: "[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] << B << endl;
    cout << [/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"Hard disk: "[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] << HD << [/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]" Gb"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] << endl;
    cout << [/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"Price: "[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] << P << endl;
    show_MB();
    show_VC();
    }
    [/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]//void main(void)
    //-----------------------------------------------------------------------------------------------
    [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]int[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] main () [/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// This is where the program starts it execution. It’s also the main function
    [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]{{
    [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]char[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] B, MBP, VCB [25];
    [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]int[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] HD, P, MBR, MBM, VCX, VCY, VCR;
    [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]int[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] X, Y; [/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// Defines variables
     
    //--------------------------------------------------------------------------------------------------------------------------------
    [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]cout << [/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"Enter number of computer sprecifications required? "[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]; [/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// Displays A Task Title
    [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]cin >> X; [/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// Stores Entered Values
    [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]for[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] ( Y=X; Y>=X; Y--); [/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// Starts repeating statemen
    [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]
    [/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]//--------------------------------------------------------------------------------------------------------------------------------
    [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]{{{{{{{{{{
    cout << [/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"Please Enter Brand? "[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]; [/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// Displays A Task Title
    [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]cin >> B; [/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// Stores Entered Values
    [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]cout << [/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"Please Enter Hardrive Size? "[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]; [/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// Displays A Task Title
    [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]cin >> HD; [/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// Stores Entered Values
    [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]cout << [/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"Please Enter Price? "[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]; [/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// Displays A Task Title
    [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]cin >> P; [/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// Stores Entered Values
    [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]cout << [/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"Please Enter Processor? "[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]; [/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// Displays A Task Title
    [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]cin >> MBP; [/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// Stores Entered Values
    [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]cout << [/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"Please Enter Motherboard RAM? "[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]; [/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// Displays A Task Title
    [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]cin >> MBR; [/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// Stores Entered Values
    [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]cout << [/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"Please Enter Motherboard Memory? "[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]; [/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// Displays A Task Title
    [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]cin >> MBM; [/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// Stores Entered Values
    [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]cout << [/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"Please Enter Graphics Card Brand? "[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]; [/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// Displays A Task Title
    [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]cin >> VCB; [/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// Stores Entered Values
    [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]cout << [/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"Please Enter X Display? "[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]; [/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// Displays A Task Title
    [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]cin >> VCX; [/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// Stores Entered Values
    [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]cout << [/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"Please Enter Y Display? "[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]; [/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// Displays A Task Title
    [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]cin >> VCY; [/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// Stores Entered Values
    [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]cout << [/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"Please Enter Video Card RAM? "[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]; [/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// Displays A Task Title
    [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]cin >> VCR; [/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// Stores Entered Values
    [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]}}}}}}}}}};
    [/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]//-----------------------------------------------------------------------------------
    [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]{ 
    COMPUTER PC([/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"B"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2], HD, P, [/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"MBP"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2], MBR, MBM, [/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"VCB"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2], VCX, VCY, VCR); PC.show_COMPUTER(); 
    [/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]//return(0);
    [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]}}
    system([/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"pause>nul"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]); 
    };
    [/SIZE]
     
  2. xpi0t0s

    xpi0t0s Mentor

    Joined:
    Aug 6, 2004
    Messages:
    3,012
    Likes Received:
    203
    Trophy Points:
    0
    Occupation:
    Senior Support Engineer
    Location:
    England
    Doesn't it already do that? What does it do if you enter 3 at "Enter number of computer sprecifications required?"; after you've entered the first details it looks like it should loop back to "Please Enter Brand?", although it's not so easy to tell with your brace abuse and lack of indentation.

    Here's how braces and indentation are supposed to work:
    Code:
    somecode();
    for(some;loop;stuff)
    {
        loop();
        code();
    }
    
    This is much clearer than
    Code:
    somecode();
    for(some;loop;stuff)
    {{{{{{{{{{{{{{{{{{{{{{{{
    loop();
    code();
    }}}}}}}}}}}}}}}}}}}}}}}}
    
    and once you start getting into proper programming with multiple nested code blocks you'll find your current style extremely difficult to read. Programming's already hard enough, why make it harder?
     
  3. icechef

    icechef New Member

    Joined:
    Feb 21, 2009
    Messages:
    10
    Likes Received:
    0
    Trophy Points:
    0
    Yeah it should loop but wont will try what you have said. Also I have found that there are 3 inputs that I have specifed as characters. but when unputed it causes the program to complete to the end. Any ideas?
     
  4. xpi0t0s

    xpi0t0s Mentor

    Joined:
    Aug 6, 2004
    Messages:
    3,012
    Likes Received:
    203
    Trophy Points:
    0
    Occupation:
    Senior Support Engineer
    Location:
    England
    Exactly what input do you give and what output do you get?
    If you run the program and copy and paste from the window directly into the edit box here that's probably the easiest and most accurate way.
     
  5. xpi0t0s

    xpi0t0s Mentor

    Joined:
    Aug 6, 2004
    Messages:
    3,012
    Likes Received:
    203
    Trophy Points:
    0
    Occupation:
    Senior Support Engineer
    Location:
    England
    Oh hang on...just have another quick look at this line:
    Code:
    for ( Y=X; Y>=X; Y--);
    
    There are several things wrong with this line. Try it in a small test program and see if you can find them all, e.g.
    Code:
    int main()
    {
      int X=10, Y;
      for ( Y=X; Y>=X; Y--);
      {
        printf("%d\n",Y);
      }
      return 0;
    }
    
    (edit: thought I'd better indent as per my own advice)
     
  6. icechef

    icechef New Member

    Joined:
    Feb 21, 2009
    Messages:
    10
    Likes Received:
    0
    Trophy Points:
    0
    Hi, Sorry I have tried but am very new to this, any chance you could alter the code so it matches mine and will run! if I just then copy and paste.
    Thank You
     
  7. xpi0t0s

    xpi0t0s Mentor

    Joined:
    Aug 6, 2004
    Messages:
    3,012
    Likes Received:
    203
    Trophy Points:
    0
    Occupation:
    Senior Support Engineer
    Location:
    England
    > any chance you could alter the code so it matches mine and will run!

    No, sorry, just giving you the answer doesn't help you in any way. I'll give you pointers and help you solve problems. Programming is a skill learnt be doing not by looking at other people's complete code examples.

    Best advice I can give you as a newcomer is to Keep It Simple, Stupid (KISS). Just get the minimum possible stuff working first, then extend afterwards. Even as a seasoned programmer of...hmm, 2009-1981=28 years! I still do this.

    Besides I don't think you're actually that far off solving this. Just do the loop test I suggested and see if you can find all the problems with that line of code. I assume that the intent of your loop is to count down from X to 1, so the output should be 10 9 8 7 6 5 4 3 2 1, but what is it and how can you fix it so that it does that?

    One thing worth knowing is that for (A; B; C) { D; } is equivalent to A; while (B) { D; C; } (yes, really D then C) so as an experiment you might try rewriting the for loop as a while loop.
     
  8. icechef

    icechef New Member

    Joined:
    Feb 21, 2009
    Messages:
    10
    Likes Received:
    0
    Trophy Points:
    0
    I need the loop so that the user defines homw lots of info required to input eg 5. then he can input the information into the relevant catorgory 5 times.
     
  9. xpi0t0s

    xpi0t0s Mentor

    Joined:
    Aug 6, 2004
    Messages:
    3,012
    Likes Received:
    203
    Trophy Points:
    0
    Occupation:
    Senior Support Engineer
    Location:
    England
    Yes, I know what you need the loop for.
    Did you try the small test that I suggested? If not, out of interest why not?
     
  10. icechef

    icechef New Member

    Joined:
    Feb 21, 2009
    Messages:
    10
    Likes Received:
    0
    Trophy Points:
    0
    worked out what was wrong with loop now working changed it to this
    (Y=0; Y<X; Y++)
     

Share This Page