C :: Food Calculator Doesn't Calculate - Choice Menus Not Display Properly?

Dec 7, 2013

I'm new to c i've been trying to write code everyday, and recently ive been reading a book and decided to write my own program with what ive learned with it, basicly you get a choice for how many different main courses you would like to have (right now you can only choose 1) and then you can choose which course you would like, it then asks for the amount of guests you would like and calculates how much food you will need to feed the guests. My code compiles but the program doesn't work properly

Code:
#include<stdio.h>

float guests;
float lbs;
int guest_att(guests)
{
puts("how many guests will be attending?");
scanf("%d",& guests);

[Code] .....

and this is how the program runs

Code:
Scotts-MacBook-Pro:learnc scott$ ./wed
how many main course choices will you have?
1

Please make a selection.
1. Chicken
2. Fish
3. Steak
invalid choice

Please make a selection.
1. Chicken
2. Fish
3. Steak
1
how many guests will be attending? 55

You need 0.000000 pounds of of chicken

Please make a selection.
1. Chicken
2. Fish
3. Steak
invalid choice

Please make a selection.
1. Chicken
2. Fish
3. Steak

View 3 Replies


ADVERTISEMENT

C :: Program Doesn't Properly Compute Simple Polynomial

Feb 7, 2014

The program will ask for the user to enter a value for x, then compute the following polynomial: 3x^5 + 2x^4 - 5x^3 - x^2 + 7x - 6.However, when I double check it with my calculator I get a wrong answer for random values of x. To simplify my problem I'm using only integers.

Code:

#include <stdio.h>
int main(void)
{
int x, polynomial;
}

[code]...

View 5 Replies View Related

C :: Calculator Doesn't Compile - Not Printing Result

Mar 16, 2014

I'm new to C, and I'm trying to write a program that gets a string, divides it into terms and operators, reduces them and prints the result. I know the source code doesn't do exactly that, yet (specially the last part), but I'd like to compile it.

Code:
#include <stdio.h>
#include <string.h>
int main ()
{
/* Write a welcome message. */
printf ("
Calculator

I use Bloodshed Dev-C++ with Ming-W and I get quite a few errors when I try to compile it.

View 6 Replies View Related

C :: Calculate Equations Just Like A Standard Calculator

Oct 23, 2013

The main point of the program is to calculate equations just like a standard calculator but I wanted to do it myself. I don't understand what the problem is right now but I've managed to create a program that asks for both values but somehow it doesn't want to ask for an operator (*, /, + etc). What's wrong with my code that the terminal skips the scanning part for the operator?

Code:

#include <stdio.h>
int main() {
int value1, value2, answer;
char operator;

[code]....

View 12 Replies View Related

C/C++ :: How To Make Food Ordering Program Utilizing Voice Commands

Apr 19, 2014

I was interested in making a food ordering program utilizing voice commands. I hope to build a GUI with items listed on one side, and with voice commands picking up on key words that will add the food to the right of what you chose.

View 4 Replies View Related

Visual C++ :: Caching MFC Menus

Jul 13, 2013

I have an VS 2010 VC++ project. I have changed a few things in the .rc file but the changes are not appearing when I debug the program. I have taken the .exe to another computer and the changes appear. Is there something that caches the resources? There are no errors when I compile or debug the program. I have tried "build clean", "rebuild" and "build solution". I have also tried to remove the whole debug directory. I have looked at the .res file in the debug directory and it has the changes.

View 13 Replies View Related

C++ :: Memory Cost On The Loop Of Menus?

Jun 26, 2014

I have a question on the wasting of the memory on the use of menus. What is the task: I have mainMenu, subMenu1, subMenu2, subMenu3, ... Entry from mainMenu, and chose 1(or 2, 3,..) to subMenu1. If tasks done, go back to the mainMenu.

The Codes:

void mainMenu(){
//input 1-3 by user
switch(choice) //choice is the input

[Code].....

My problem is: the call for mainMenu() in subMenus looks like a recursion, which means the memory would be reallocated again for the called maniMenu. Is that right?

If so, times of the memory space for mainMenu function are required if going back to mainMenu several times from subMenus. But what i wanna just a choice and I dont want to wast the memory.

View 4 Replies View Related

C++ :: Calculate Sum Of Integer And Display To User

Mar 4, 2014

A problem that lets the user enter any positive integer, but you do not have to check for this, and then calculates the sum of the digits and displays this to user. For example, if user enters 14503, the outputted sum of the digits would be 13.

Here is my program

#include <iostream>
int main(void) {
int integer, sum=0;
while(integer) {
sum += integer % 10;
integer /= 10;
} cout << "The sum of the integers numbers is " <<sum;
return 0;
}

View 5 Replies View Related

C++ :: Write A Program That Uses Arrays To Calculate Sum And Display It

Nov 4, 2013

SO Im supposed to write a program that uses arrays to calculate the sum and display it. I keep getting the error that says the sum has to be initialized.

#include <iostream>
using namespace std;
//Function prototype
int sumArray(int);
const int NUM_ELEMENTS = 5;

[Code] .....

View 1 Replies View Related

C++ :: Randomized Multiple Choice

Feb 20, 2012

I have gotten my code sorted out, and now it works. But to be adaptable to 3pi robots, which I will be loading it into eventually, the user has to be given three letter (a, b, c) multiple choices for answer input to the math questions. The three choices have to be randomized everytime the program loops too. Currently it just runs on number input.

Code:

#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <math.h>
int menu();
void addition(int *Preward); // function to return truth values
void subtraction(int *Preward);

[Code] ....

View 4 Replies View Related

C++ :: Reading Int Choice In With A String Buffer Instead Of Cin?

Sep 25, 2013

How do you read an int choice in with a string buffer instead of cin?

View 2 Replies View Related

C# :: Multiple Choice Symptom Checker?

Mar 9, 2015

I'm doing a project through college which is a diagnostic and support tool for Windows OS's. The application at the moment has a simple expert system which is a Combobox with strings that relate to common PC problems. Then those strings are put through a switch statement and relevant commands are shown to fix the problem i.e. "My printer is not working" will disable all buttons except for printer management, spooler folder etc.

My supervisor who marks my project has said this isnt good enough and wants a more layered hierarchy approach so he's looking for 3-4 groupboxes with tickboxes inside them and users tick the boxes that relate to their problem which will give the functions to support. The only way I can see to do this at the moment is a massive nested switch statement that is really not worth the time. There are 60+ functions in my program so you can imagine how long the switch would be trying to pick and iterate through all of the possible answers.

I'm just trying to figuire out an easier way to do this, rather than a massive switch statement. Something like WebMD which has 4-5 tick boxes and can give out the same answer for different symptoms.

I've attached a Flow Chart I made of the hierarchy Im trying to go for [URL] .....

View 1 Replies View Related

C/C++ :: Tic Tac Toe Game - Creating A Menu/choice

Nov 11, 2014

Im trying to create something like a menu in a tic tac toe game. I want the computer to ask the user "who starts first" is it the X or the O who starts first? Then the user should type in either X or O but if he types something else i want to ask again .

this is what ive done :

int main () {
printf("
");printf("
");
printf(" %c | %c | %c
", board[1], board[2], board[3]);

[Code] .....

View 10 Replies View Related

C++ :: Program Menu Choice Skips Over Input

Jun 1, 2013

I just recently finished up a program that implements Dijkstra's Algorithm and I thought I would make a nice little menu for the user.

so the user can input their locations, I use Getline just in case their location contains spaces. However, when the user selects 2, It skips over the first input for the "Source" location and only lets the user input for the "Destination".

Any reason why this would happen? Am I missing something with Getline? Anyway, here's the code...

template <typename V, typename E>
void Graph<V, E>::Driver() {
bool done = false;
int menu(0);
InputFile();

[Code] ......

View 2 Replies View Related

C/C++ :: Assigning Variable From Multiple Choice Answer

Oct 29, 2014

I tried to create a multiple choice list and I want to assign the value of the answer option chosen by the user so I can use it later on in the code. Later on in the code i've asked how many people (p) want a drink and multiplied it by the chosen size to calculate the price c = p * n where c is cost, n is price and p is number o of people At the bottom i tried to assign parameters where depending on what option the user has chosen n will be assigned to the chosen value...

{
printf("SELECT TYPE OF PAINT:"); /*multiple choice of paint */
printf("1. Large ");

[Code]....

View 1 Replies View Related

C++ :: Multiple Choice Function - Using Character As Parameter

Feb 20, 2012

I have a multiple choice function below that is part of a larger program but I am having trouble having it operate with characters as inputs and arguments. It has to be a character input, but I kinda want it to act like an integer, how do i do that?

Code:
void addition(int *Preward) //function that is called by the users selection {
int random1, random2;
int order;
int one, two, three;
int rando1, rando2;
char a, b, c; // ERROR

[Code] ....

View 2 Replies View Related

C :: Create Multiple Choice Quiz Works But With A Warning

Apr 10, 2013

I am trying to create a multiple choice quiz so I can learn the menu at my new job, while doing a side project but I am having a warning when outputting. Speaking of side projects, is this a kind of side project people are looking for on a resume?

Code:

#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <stdlib.h>
#include <string.h>
}

[code]....

View 8 Replies View Related

C++ :: Grading Multiple Choice Test - Getting Infinite Loop?

Nov 4, 2013

I am writing a program for grading a multiple choice test. The test data is pulled in from another file. My problem is that its only pulling in the first line of data and running an infinite loop without reading the next line of the data file.

My code is as follows:

PrintPurpose ( );
cout << student << " ";
cout << answers << " ";
inData >> key;

[Code].....

View 1 Replies View Related

C/C++ :: 5x5 Multiplication Table Starting With The Number Of User Choice?

Feb 23, 2014

#include <stdio.h>
#include <stdlib.h>
int n;
int m;
char input[20];
int num;
int main() {
int num0;

[code]....

I'm supposed to write C program that will generate a 5 X 5 multiplication table starting with the number of the users choice. The program is supposed to operate within a loop and run until the user indicates that they no longer wish to enter any more numbers. I can get the program to run but am wondering what I need to do to get the program to ask for another number and how to make the program stop when the user no longer wants to play. Should I start with "Do you want to enter a number" if yes, run back through loop if no, goodbye?

View 8 Replies View Related

C++ :: Generates Random Addition For Subtraction Depending On User Choice

Feb 17, 2012

Below is a program that generates random Addition for Subtraction problems depending on the user's choice. The user is prompted to input an answer and then it keeps your score. If you want to quit you just press zero.

Code:
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <iomanip>
#include <string>
using namespace std;
int menu();
bool addition(int &reward); // function to return truth values

[Code] ....

View 14 Replies View Related

C++ :: How To Create True False And Multiple Choice Questions Using Text Files

Jan 7, 2015

So im trying to create a quiz using c++ that incorporates three different types of questions. These are the standard one answer question, true false questions and multiple choice questions.

How to create the true false and multiple choice questions?

One way that i came up with looks like this

Question A answer1 B answer2;

View 2 Replies View Related

C/C++ :: Call To String Function To Display Names In Class Not Display

Apr 19, 2014

I created class called students which suppose to store students names of in array but when I call the display function it display only the first name. but I want it to display names depending on the array size.

#include <iostream>
#include <sstream>
using namespace std;
const int SIZE=5;

[Code]....

View 3 Replies View Related

C :: Cannot Get Strstr To Work Properly

Aug 26, 2014

I am unable to get the string seaching function to work. it always says "Nothing found" I am stumped.

Code:

#include <stdio.h>
#include <string.h>
char tracks[][80] = {
"I left my Heart at Harvard Medical School",
"Newark, Newark, You suck balls",
"Dancing with a dork",
"From Here to maternity",
"The Girl from Iwo Jima",

[Code]....

View 3 Replies View Related

C :: String Not Validating Properly?

Mar 5, 2013

1. In main() in the while loop entering 'q' does not exit.

2. in the isbnValidation function. The size check for minimum length words will work, but the check for "Invalid ISBN character" doesn't.

3. Every ISBN entered returns as valid. The formula is supposed to multiply the first digit by 10, next by 9 etc (skipping all the dashes) and add up to a weighted total which if valid will divide evenly by 11.

Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ISBNMIN 10
#define ISBNMAX 14

[Code].....

View 4 Replies View Related

C++ :: File Is Not Reading Properly?

Mar 30, 2013

I have a file which I am unable to read properly. This is binary file so my code is"

#include<iostream>
#include<fstream>
#include<string>

[Code]....

the file to read can be download from this link :

[URL]

The first content of file should be 1 I am missing few content from the begining

View 2 Replies View Related

C++ :: How To Properly Iterate Over A Container

Oct 31, 2013

so i have a container called Source that is of type std::map<std::string, std::vector<std::string>> but when I try to print it with this function:

void Lexer::PrintSource()
{
for(auto Iterator = this->Source.begin(); Iterator != this->Source.end(); Iterator++)
for(auto SubIterator = Iterator->begin(); SubIterator != Iterator->end(); SubIterator++)
cout<< *SubIterator << endl;
}

i get these errors:

Lexer.cpp: In member function 'void Lexer::PrintSource()':
Lexer.cpp:29:42: error: 'struct std::pair<const std::basic_string<char>, std::vector<std::basic_string<char> > >' has no member named 'begin'
for(auto SubIterator = Iterator->begin(); SubIterator != Iterator->end(); SubIterator++)
^
Lexer.cpp:29:76: error: 'struct std::pair<const std::basic_string<char>, std::vector<std::basic_string<char> > >' has no member named 'end'
for(auto SubIterator = Iterator->begin(); SubIterator != Iterator->end(); SubIterator++)
^

View 6 Replies View Related







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