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
ADVERTISEMENT
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
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
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
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
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
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
Apr 7, 2013
For an assignment I am having a user enter the name of a file that contains "Song Data" the file is set up like this:
(example)
1012 C
3333 R
90 E
And so forth for 15 lines. The first value represents the song Id and the second is a character C, D, E, or R that represents the type of song. After the file is opened I have two parallel arrays that are read from the file:
1. int songId[15]
2. char typeOfSong[15]
I am able to read the entire file, which symbolizes playing the playlist in order, but now I have to play a randomized playlist.
It has been given to us that we need to set up two parallel arrays, that are also parallel to the first two (songId and typeOfSong). These must also be one dimensional. The first array will will be indexes into the songId array telling is what order to put the songs in and the second is an array of true/false values telling us if the song has already been chosen or not.
I have that:
void playRandomPlaylist (int songId[], char typeOfSong[]) {
// the size of the file and therefore arrays is known
rand() % songId[15]
// choosen and notChoosen symbolizing true and false values
typedef enum {choosen, notChoosen};
}
View 1 Replies
View Related
Oct 11, 2013
how to count and display the palindromes in this randomized letters:
this is my program but it only prints randomized letters and can't count the palindromes words and display it:
Code:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
[Code].....
View 2 Replies
View Related
Jun 26, 2013
This program is sorting a randomized array of integers using the bubblesort algorithm.
I am trying to modify n correct the source code,so that the swapping of two values will be done by a function called swap values() by using call-by-reference but function should have as arguments only the two array elements that must be exchanged. (Note: do not pass the whole array to the function!) .We consider an array with the first element containing the number of elements in the array, followed by 10 randomly initialized integers (elements).
The code must sort the 10 elements in ascending order.
Compile: g++ -Wall sorting.cpp -o sorting
*/
#include <iostream>
#include <stdlib.h>
using namespace std;
int main() {
const int SIZE=10;
[Code] .....
View 1 Replies
View Related
Sep 25, 2013
How do you read an int choice in with a string buffer instead of cin?
View 2 Replies
View Related
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
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
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
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
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
View Related
Jul 31, 2014
I want to develop an application which can host multiple views of explorer (window), where as each window is totally separate from others. So that I can have multiple desktop views through my single explorer. Any built in feature in .NET ?
View 11 Replies
View Related
Aug 17, 2014
how to make subroutines and return multiple arrays.Before that, i wrote my program on matlab. could my program to be structured as following?
<header>
initial value of program;
subroutine1() {
calculating the first work;
return 2 or 3 arrays;
[code].....
View 14 Replies
View Related
Mar 21, 2014
I've been working on a function that works like a pipeline of a shell but receives a directory, go over it an search for every file to send it to a filter, something like this in bash "cat dir/* | cmd_1 | cmd_2 | ... | cmd_N", The only problem i have with the code is the redirection of the pipe descriptors.
Code:
int main(int argc, char* argv[]){
char** cmd;
int Number_cmd;
cmd = &(argv[2]); /*list of cmds*/
Number_cmd = argc-2; /*number of cmds*/
}
[code]....
The code is seems to work fine except when i run it with more than one command in example ("./filter DIR wc rev") in this case it returns
wc: standard input: Bad file descriptor
wc: -: Bad file descriptor
0 0 0
View 2 Replies
View Related
Jul 15, 2013
I'm using multiple C++ files in one project for the first time. Both have need to include a protected (#ifndef) header file. However, when I do that, I get a multiple definition error.
From what I found from research, adding the word inline before the function fixes the error. Is this the right way to do this, and why does it work? Should I make a habbit of just declaring any function that might be used in two .cpp files as inline?
View 5 Replies
View Related
Mar 1, 2012
Say I have 5 vectors of unsigned char each of size 5. I want to take the max of each index and store it in a new vector. What is the most optimal way to accomplish this?
My slow code:
Code:
vector<unsigned char> vec1;
vector<unsigned char> vec2;
vector<unsigned char> vec3;
vector<unsigned char> vec4;
[Code]....
View 3 Replies
View Related
Apr 1, 2014
My professor asked my to make a program that makes the "FCFS","SWJ" operations using any programming language actually i preferred c++ i like it more than java so i started in it but i'm facing a little problem ,,, which is i cant enter multiple inputs with a space tabs between them if this possible , for example : i want to get the arrival time and execution time from user
arrival (spaces " ") execution >> i want the input be like this
input1 (spaces " ") input2
View 10 Replies
View Related
Jul 18, 2012
Class1 {
public:
int value;
Class1(int value) {
this->value = value;
[Code] .....
i want use like this for that what can i do ...
std::map<class, Class2> map_Class;
View 1 Replies
View Related
Nov 28, 2011
I made a working version using absolute vextors being rotated by matrices and keeping relative vecotrs for translations. What I didnt like is that I HAVE TO use the standard XYZ axis for rotation.What I decided to do was use quanternions to store current rotation,cthen buffer rotations each time some were done and add it up.The way I see it, it should look somewhat like this:
(in the UpdateRotation part, plz dont mind any typos i make, this isnt the actual current code. Also on a small note I use dictionaries, so dont be surprised xD) Code: RelativeVectors["Up"] = Vector3.Transform(AbsoluteVectors["Up"], (Quanterion)CurrentRotation);
//repeat for Look and Right relative vectors
Quanternion Yaw = Quanternion.CreateFromAxisAngle(RelativeVectors["Up"], RotationBuffer["Yaw"]);
//repeat for roll and pitch
CurrentRotation = Quanternion.Contancate(CurrentRotation,(Yaw*Pitch*Roll));
//
clear the rotation buffer Whats happening right now tho, is that doing this exactly doesnt actually do anything, so I have to use standard axis anyway.
View 1 Replies
View Related
Jan 22, 2013
I am getting an error on lines 31 and 36 about an expected identifier on my program that computes area and circumference. Is something wrong with my external functions outside of main?
Code:
#include <stdio.h>
#define PI 3.14159
double area;
double circum;
double find_circum (double radius);
double find_area (double radius);
[Code] ....
View 2 Replies
View Related
Aug 20, 2014
Can I a have one pointer with two reference in it. Here's what I've got.
Code:
char* c;
char x='x' , y='y';
c = &x;
c = &y; -- or --
Code: char* c[2];
char x='x' , y='y';
c[0] = &x;
c[1] = &y;
If it's possible I want to apply it to make AST.
View 8 Replies
View Related