User Profile

Collapse

Profile Sidebar

Collapse
16800960
16800960
Last Activity: Jun 4 '10, 03:11 AM
Joined: May 21 '10
Location:
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • 16800960
    replied to bool findTitlePrice function code help
    in C
    I have the code to this point

    Code:
          # include <iostream>
    
          # include <string>
      
          const int MAXSIZE = 300;
      
          using namespace std;
     
          bool findTitlePrice(string allTitles[MAXSIZE], double allPrices[MAXSIZE], int totalRec, string title, double price); //the names of the parameters are optional
      
          string allTitles[MAXSIZE] ={
    ...
    See more | Go to post

    Leave a comment:


  • the specifications Dheera is that the data is stored in the arrays not that i have to use the arrays to delete though that was i what i was assuming as it would be easiest.

    as far as the delete wouldn't i have to find the element which matches the getline string then set element = number 1 lower and apply this to all larger elements

    something similar to this maybe

    for ( i = 0; i < n; i++ ) {
    ...
    See more | Go to post

    Leave a comment:


  • first function is to search the array for the matching title

    then select the position of the match then remove that position and update the total rec


    Then the Price is done similarly though it selects based on the psoiton of the title though

    really i would

    search for string title " book2"

    use a for loop which will show

    the position of alltitles[i]
    ...
    See more | Go to post

    Leave a comment:


  • the logic behind the -- functions though they are not declared correctly was if a matching title is found it is meant to remove the record from the arrays the reason two arrays are used is that the program specifies that the two arrays must be present and executed before the menu appears


    i had a better for loop for the other section though i would use a list as long as i can point it to the arrays cannot use classes unfortunately...
    See more | Go to post

    Leave a comment:


  • C++ Switch Statement within program to perform multiple functions

    Here is the code for my program
    Code:
    // Book Price (16800960)
    
     
      #include <iostream>
      #include <string>
     #include <iomanip>
    
     const int MAXSIZE 300;
    
     using namespace std;
     void displayMenu ();
     void listRecords(string allTitles[300], double allPrices[300], int totalRec);
    
     string allTitles[MAXSIZE] = {
            "Book 1",
    ...
    See more | Go to post

  • 16800960
    replied to bool findTitlePrice function code help
    in C
    I tried that but it stated undeclared functions when i used it

    with error expected ; before for


    So i put it in there and the error went away i do understand the concept of functions try compiling my code

    and remove the ; see what happens using devC++


    Apart from that does the rest seem okay or am i getting further off course i need to get this working


    Thanks again...
    See more | Go to post

    Leave a comment:


  • 16800960
    replied to bool findTitlePrice function code help
    in C
    I think i hav efindTitlePrice Declared Okay

    Code:
    # include <iostream>
    # include <string>
    # define MAXSIZE = 300
    using namespace std;
    
    bool findTitlePrice(string allTitles[300],double allPrices[300],int totalRec,string title,double price);
    
       string allTitles[300]  ={ 
            "Book 1",
            "Book 2"
    };
        double allPrices[300]
    ...
    See more | Go to post

    Leave a comment:


  • 16800960
    replied to bool findTitlePrice function code help
    in C
    it is meant to return false if it fails to find a match hence the else statement. yes i also realized that he call to findTitlePrice should be done in main will post if i have any issues with this section of code it is mainly the

    if title == function that i need to get right.
    See more | Go to post

    Leave a comment:


  • 16800960
    replied to bool findTitlePrice function code help
    in C
    No OOP concept i agree there are sill some errors mainly just need the check function figured out to cout the Title when the match is found and then the mathcing price can you check that i have declared that correctly there are erros with {} in some of the sections that is due to the complier throwing up errors

    So to Define the Program has to use the BOOLFINDPRICE function then check if a mathc is found if a match is found cout the element...
    See more | Go to post

    Leave a comment:


  • 16800960
    replied to bool findTitlePrice function code help
    in C
    I have got it looking like this

    Code:
    # include <iostream>
    # include <string>
    # define MAXSIZE = 300
    using namespace std;
    
    bool findTitlePrice(string allTitles[300],double allPrices[300],int totalRec, string title,double & price);
    
        string allTitles[300] = {
            "Book 1",
            "Book 2"
        };
        double allPrices[300]
    ...
    See more | Go to post

    Leave a comment:


  • 16800960
    replied to bool findTitlePrice function code help
    in C
    I know basically i was meaning to set a true condtion which would return true else return false


    so realistically a single if statement if (title == AllTitles [i])

    {

    Cout << " Match Found "

    Return True;


    Else

    Cout << Match Not Found

    Return False;


    and Pause


    TotalRec was hardcoded to...
    See more | Go to post

    Leave a comment:


  • 16800960
    replied to bool findTitlePrice function code help
    in C
    I don't know that he code you posted doesn't work if i offended you i am sorry


    The code above is the latest another variation is as follows if it is more usable

    Code:
    # include <iostream>
    # include <string>
    # define MAXSIZE = 300
    using namespace std;
    
    bool findTitlePrice(string allTitles[300],double allPrices[300],int totalRec, string title,double & price);
    ...
    See more | Go to post

    Leave a comment:


  • 16800960
    replied to bool findTitlePrice function code help
    in C
    I figured that the choice of field was wrong but can you help me define my code better


    Basically

    Say write a check if
    cin value >> "Title" ==
    allTitles []

    cout "the Book was found"
    return true


    else
    cout << "Book not found"
    return false"

    the code you seem to write is C

    i need C++...
    See more | Go to post

    Leave a comment:


  • 16800960
    replied to bool findTitlePrice function code help
    in C
    Here is the code i have at the moment there ar eno complier errors but want to make sure that the function is set to check the cin inut matches any element in the ararys

    Code:
    # include <iostream>
    # include <string>
    # define MAXSIZE = 300
    using namespace std;
    
    bool findTitlePrice(string allTitles[300], double allPrices [300],int totalRec,string title,double price);
     
     string
    ...
    See more | Go to post

    Leave a comment:


  • 16800960
    replied to bool findTitlePrice function code help
    in C
    That maybe true but program specifications are to use arrays so that is whyI have done so basically all i need is the statement to check if cin >> "title" matches array alltitles [i] if there is a match grab the corresponding price from the allPrices [i] as an example i already know to return true if condition is met and return false if it does not match just need to figure out how to write the check and determine if i have prototyped...
    See more | Go to post

    Leave a comment:


  • 16800960
    replied to bool findTitlePrice function code help
    in C
    No it doesn't it is meant to be a find match then return bool type so i chose true and false as the representative terms

    Dheeraj

    how would i express this yes it is meant to check the array all titles then return the value say ith record in the allprices array as well as they store the same amount of records and are matched arrays so if it was say record 3 in titles that matches the input string then grab the price from...
    See more | Go to post

    Leave a comment:


  • 16800960
    started a topic bool findTitlePrice function code help
    in C

    bool findTitlePrice function code help

    The Code is as Follows
    Code:
    bool findTitlePrice(string allTitles[], double allPrices[],
    int totalRec, string title, double & price)
    {
    for(int i=0; i < totalRec; i++)
    {
    // your code here:
    // for each element of array allTitles, check if it matches
    // the given title, i.e. if title and allTitles[i] are the same;
    // if yes, fetch the corresponding price from
    // the array
    ...
    See more | Go to post

  • 16800960
    replied to Help Void Skip Blanks ()
    in C
    Thanks BanFa i realise i should use endl though /n flushes th eline decreasing the chance of overloading the function right.

    so basically your saying declare above main

    Void DisplayMenu ()

    Then in Main Displaymenu (){ cout Statements }

    End.

    I know that it will cout if i declare as void dipslay menu (); { Cout

    what i want is function displayMenu () to display i keep getting...
    See more | Go to post
    Last edited by Niheel; May 27 '10, 09:13 AM. Reason: unnecessary lines

    Leave a comment:


  • 16800960
    replied to How to make a menu in C++
    in C
    something with a switch statement

    Cout << Menu Options

    int menu
    Switch (Menu)

    case 1:

    Cin << Etc;

    something like this
    See more | Go to post

    Leave a comment:


  • 16800960
    replied to Help Void Skip Blanks ()
    in C
    Have fixed the pause and CLS code now need the code to

    Code:
    void displayMenu (){
       cout << "MAIN MENU\n";  stringchoices []=
    {cout << " 0. Exit "; cout <<  " 1. Enter Book "; cout << " 2. Find Book\n ";
    cout << "3. List All";    "4. Delete Book";   "5. Update Book\n";}
    I want to make...
    See more | Go to post

    Leave a comment:

No activity results to display
Show More
Working...