C++ :: Program That Ask User To Input 5 Books With ISBN Title Of Book With Author

Jan 29, 2013

So I was asked to create a C++ program that will ask the user to input 5 books with the ISBN, Title of the book and author/s. It will ask for 3 authors, if the book has only one author, you should leave "author 2 and author 3" blank and display only one author. Thing is... I'm having a problem with the if else condition at the last part of my program. I cant seem to make it work.

#include <iostream>
#include <cstring>
#define SIZE 5
using namespace std;
int i;

[Code]...

View 9 Replies


ADVERTISEMENT

C :: Compute Total Price Of Books By A Given Author

May 7, 2013

Given a structure book defined as follows and an array lib of books

Code:
struct Book{
char title[100];
char author[100];
int price;
struct Book *nextedition;
};

struct Book lib[1000]; I'm going to write a function to compute total price of books by a given author including all books which are future editions of his book, even if the author of that future edition is NOT the specified author. title author price nextedition Book1 Author1 25 &lib[2] Book2 Author2 20 NULL Book3 Author3 30 &lib[3] Book4 Author1 35 NULL
For the example above, given the author "Author1", the function should return 90 (=25+30+35), and given the author "Author 3", the function should return 65 (=30+35).

So here's my attempt:

Code:
int totalPrice(char author[100]){
int total=0;
for (i=0; i<numbooks; i++)
if(strcmp(author, lib[i].author==0))

[Code] ....

What I'm trying to do is finding the first book in the lib of the specified author using for loop and then let the while loop do the rest. However, it seems the price is over-counted after each iteration of the for loop but I don't know how to fix it.

View 2 Replies View Related

C/C++ :: How To Ask A User To Enter Date And ISBN Number In Specific Format

Dec 4, 2014

I don't know how to ask the user to enter the date in this format (DD/MM/YY) and ISBN number with hyphens.

After user enter date and ISBN number, it should look like this:

Date: 5/24/12
ISBN: 0-000-12345-0
#include <iostream>
#include <string>
using namespace std;
int main() {
string date;//MM/DD/YY Format

[Code] ....

View 7 Replies View Related

C++ :: Library Program To Add Information About Books In Binary File

Jan 3, 2015

I am working on binary files in turbo c++ 3.5 and i want to create a library program. I want to add information about books in a binary file and do functions such as: Search and replace, delete a record, and etc.

I do this functions but i have 2 problems: 1. For example when i add 6 records about books to file, BooksReport function cant show all records and for example just show 4 or 5 records and when i search records, from 5 records, for example i just found 3 or 2 records. 2.When i search and replace a word on file, all records thats before this edited record, will be deleted.

#include <conio.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void add();
void search();
struct {
char name[20];

[Code]...

View 2 Replies View Related

C++ :: Address Book - Program Stops After Cin

Dec 6, 2013

the program is of an address book. the syntax is all fine, and the initial menu of options does show up. but once you punch in the cin, the program just stops.

View 9 Replies View Related

C++ :: How To Get Program Recognise User Input

Dec 8, 2013

I need the program to do a calculation after the user inputs 10 numbers . This is what I have tried so far:

int count;
float value, high,low, sum,average;
sum=0;
count=0;

input:
printf("Enter a number (enter negative value to finish program):
");
scanf_s("%f",&value);

[Code] ....

output:
average=sum/count;
if(count==10) {
printf("total values :%d
",count);
printf("The Highest value :%f
Lowest Value: %f
",high,low);
printf("The average of the values is:%f
",average);
}

View 3 Replies View Related

C++ :: Program That Accepts Two Input From User?

Dec 8, 2013

I built a program that accepts two input from the user, using a array inside a loop, it is pass to a function inside a class which will display the two number, the problem is when the user is inputting a number and it is 1 the program continuously as the user to input a number, and when 2 is entered the program ask another number and end, but for example you entered 2 and 3. . . it will then outpu 2 and 4 (so 3 + 1 ) and always the last number is plus one. here is the code.

main.cpp
#include <iostream>
#include "newclass.h"
using namespace std;

[Code].....

View 5 Replies View Related

C++ :: Program That Will Allow A User To Input Their First Name Into A String

Feb 23, 2015

So we have a weekend assignment that is "Write a c++ program that will allow a user to input their first name into a string, and use the switch/case statement to produce the following output. Your Program should prompt the use rwith the numbers and the options for each (school, classification, and mood) allowing them to make a choice"

My issue is with the output. The output at the end is the number that they input and not the name of the case they chose, so if they chose option 1 for school it does not print out "BRCC" at the end for the output it prints a 1.

#include <iostream>
#include <string>
using namespace std;
int main(void) {
string name;
cout << "Please enter your name: ";
cin >> name;

[code].....

View 7 Replies View Related

C++ :: Program That Accept Input For User ID

Oct 28, 2013

I need a program to run that will accept an input for user id. It will take the customer input and capitalize the letters, and return invalid id with the user inputted values. Then if it's valid it will add a counter counting the number of letters and numbers. It will keep track until the user puts in !. It seems when I try to pass values from the array to my toUpper function to capitalize it it doesn't seem to work right.

View 3 Replies View Related

C++ :: Program Skips Over User Input?

Dec 6, 2014

I am so close to finishing this program of games, but I'm running into some issues while debugging it.

I've attached the google drive folder since there are several files (ignore the ones with [conflict], etc)...

First, I have the main menu using a switch to select the game. The default was set to exit. If initially when immediately opening the program you put in for say, a letter, it would exit like its supposed to. But if you went and played any of the games ], went back to the main screen, and entered a letter then, it would crash. I've put in a testing line to make sure that you enter a number, and not anything else.

Now however, if you play a game and then want to go back to the main menu, it will simply skip over waiting for your response and close the program. The same thing happens in the slot machine, I want to have it spin the slot machine by pressing enter, but it simply skips over the input, and I'm not sure why.

[URL] ....

View 2 Replies View Related

C++ :: How To Allow User Input To Exit The Program

Feb 20, 2013

I need to create a command where the user inputs a character and it'll exit out the program rather than executing any of the other code.

For example :

If I wanted to do like
char key;
if (key == D || key == d)
{
}

What would I need to put in between those brackets under the if statement to allow the user to enter the letter D and it would close out the program?

View 2 Replies View Related

C :: Program To Capitalize Every Other Word Of User Input

Feb 26, 2013

I'm trying to write a program that capitalizes every other word of a user output. (ex: if input is "i love you", the output is "i LoVe YoU").

I am using a for loop (although an if loop might be easier?) and I'm assuming that it is possible to write this program using a for loop (although I may be wrong--maybe only if loops can write this program). I have everything down EXCEPT the last step where I have to print the entire sequence. What i have so far is:

Code:
#include <cs50.h>
#include <stdio.h>
#include <string.h>
{
// get user input
printf("Type a sentence: ");
string s = GetString();

[Code] .....

The code above basically only prints out the capital letter (ex: input is "hello", output is "EL"). I don't know how to print out the entire sequence.

View 2 Replies View Related

C++ :: Exit Two-threaded Program With User Input?

Sep 9, 2014

// clang++ -g -std=c++11 main.cpp -pthread
#include <iostream>
#include <thread>
#include <unistd.h>
void thread1(void) {
while(1)

[code]....

Thread 1 does some background work, and thread2 is waiting for the user's input. If I join thread1 then the app can never exit. If I neither join nor detach thread1 then I get "terminate called without an active exception Aborted" which is not a good thing to have. If I do detach on thread1 does thread1 ever terminate? If not, how to terminate it? Also, how do I check if it's terminated or not?

View 2 Replies View Related

C++ :: Create A Program That Will Prompt The User For Input?

Dec 28, 2014

I need to create a program that will prompt the user for an input, then it will save their input to a file and then it will prompt the user to input "Open" and then the file containing their first input, will open up and show their input.

View 19 Replies View Related

C/C++ :: Tic Tac Toe - Program Not Stop To Read In User Input

Jan 18, 2014

It's a tic-tac-toe program. I haven't finished doing everything I need to for the project, I'm just trying to get certain parts working as I go.

Anyway, my problem: The program will print the board and ask the first player which square they want to mark. Then it will print the updated board, print the question for the second player to input their square choice but not actually stop to let the user enter anything. Instead it prints the board again and then prints the question for player one again -- this time stopping to let them type in their choice.

Here's my code:

#include <stdio.h>
// Function prototypes
void printBoard(char board[3][3]);
int main() {
int quit = 0;
// Loop so game continues until player quits

[Code] .....

And it looks like this when I run it, as an example:

-------------
| 1 | 2 | 3 |
-------------
| 4 | 5 | 6 |
-------------
| 7 | 8 | 9 |
-------------

Player 'C' enter a square: 5

-------------
| 1 | 2 | 3 |
-------------
| 4 | C | 6 |
-------------
| 7 | 8 | 9 |
-------------

Player 'U' enter a square:
-------------
| 1 | 2 | 3 |
-------------
| 4 | C | 6 |
-------------
| 7 | 8 | 9 |
-------------

Player 'C' enter a square:

View 11 Replies View Related

C# :: Lottery Console Program - User Input

Oct 21, 2014

I have an a problem I need to make lottery random generation program what asks from user how many lines to gerenate random numbers. But i am now stuck.

Console.WriteLine(" choose how many numbers ");
int i = int.Parse(Console.ReadLine());
Random randomizer = new Random();
for(int j = 0; j < 7; j++) {
i = randomizer.Next(1, 39);
}
Console.WriteLine("Your random numbers are{0}", i);
Console.ReadLine();

View 5 Replies View Related

C/C++ :: Program Crashes After Numbers Input From User

May 6, 2014

#include <iostream>
#include <string>
#include <limits> //for std: numeric limits
#include <algorithm>
//Function to get an integer from the user that is greater than or equal to zero.

int getPositiveIntFromUser(const std::string& prompt) {
int retVal = -1;

[Code] ....

The first part works, but it doesn't calculate the GCD or LCM at all, it just crashes!

View 2 Replies View Related

C++ :: Exit Two Threaded Program With User Input?

Sep 8, 2014

Code:

// clang++ -g -std=c++11 main.cpp -pthread
#include <iostream>
#include <thread>
#include <unistd.h>
void thread1(void) {
while(1) {
int i = 88 * 2;

[Code]...

Thread1 does some background work, and thread2 is waiting for the user's input.

If I join thread1 then the app can never exit. If I neither join nor detach thread1 then I get "terminate called without an active exception Aborted" which is not a good thing to have.

If I do detach on thread1 does thread1 ever terminate?
If not, how to terminate it?
Also, how do I check if it's terminated or not? -- I realize it's platform specific, I am on Linux.

View 5 Replies View Related

C :: Program Works Primarily By Receiving User Input

Jun 24, 2013

My program works primarily by receiving user input however; using 'char' and 'fgets' i have to stipulate how many characters i want assigned, and this isn't practical for what I am after. Example below.

Code:

char example[50];
printf("What colour is the sky?
");
fgets(example, 50, stdin); Is it possible that the assigned number (in this case '50') is determined strictly by the user input?

for example, user input is Blue then 50 is then 5?

View 9 Replies View Related

C :: Program That Allow User To Input String Then Scans The File

Sep 21, 2014

This program will allow the user to input string then scans the file if it contains the same string given by the user. But i always get "MATCHED" even if i enter random string. I tried and tried to place the if statement in different positions but i dont get my expected output.

Code:
#include<stdio.h>#include<stdlib.h>
#include<time.h>
#include<string.h>
int main() {
int found;

[Code] ....

View 6 Replies View Related

C :: How To Write A Program To Make The User Input With Text

Sep 22, 2013

I need to write a program to make the user input some text, and the first letter of each word has to be uppercase. (have to use while loops)

So for example lets say the user inputs:

i lOvE pRoGrAmMiNg

The output needs to be:

I Love Programming

Code: int main()
{
char c, lower_c;
printf("Enter Text");
while (c != '' && c >= 0)
{
if (c >= 'A' && c <= 'Z')
lower_c = c + 32;
else
lower_c = c;

[Code]...

I have started this code by making the letters lowercase (I don't know if this was the right way to approach this, ). I am not sure how proceed after this step, the step of making the first letter uppercase. (PS for the program, loops should be while loops)

View 6 Replies View Related

C :: Program That Counts Letters Of 3 Lines Of Input From User

May 26, 2013

So I am writing a program that counts the letters of 3 lines of input from the user. I am using a 3 x 80 character array as the "notepad". Upper and lower case characters are incremented on the same counter array.

Code:

/*Letters in a string*/
#include <stdio.h>
#include <string.h>
#include <ctype.h>
void countAlphabet(char *);
/*Character counting array*/
int alphabet[26] = {0};

[Code]...

View 3 Replies View Related

C++ :: Program Which Allows A User To Enter Input For A Time Interval

Apr 23, 2014

how can i make a program which allows a user to enter an input for a time interval for example i ask a question and sets the input to be entered within 10 seconds...

View 4 Replies View Related

C++ :: Create A Program That Will Let User Input Amount In Form?

Jan 4, 2014

Figure this out using [TURBO C]

Create a program that will let the user input an amount in the form (367). The Program should determine the no. of coins for each dominations : 50,25,10,5,1. (using Turbo C)

View 7 Replies View Related

C++ :: Writing Program That Asks User To Input Number?

Sep 11, 2013

im writing a program that asks the user to input a number 1-10 and will transform it into the roman numeral of that number but it seems that its not after the user inouts the number nothing will output

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

[Code]....

View 3 Replies View Related

C++ :: Program Which Takes Date And Time Input From The User

Jan 20, 2013

I am writing a C++ program which takes date & time input from the user. This is then parsed into a struct such as:

struct time
{
short year;
short month;
short day;
short hour;
short min;
};

My question is: how can I convert such a struct into a time_t object, which is an unsigned long giving the time as the number of seconds elapsed since the epoch Jan 1st 1970, 00:00, as set out in time.h.

I am wondering if this can be achieved using the standard library, or whether I just need to write a function to perform the appropriate arithmetic.

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved