C++ :: Program For Calculating Total Price Of Game Station And Game
Sep 13, 2014
I would like to make a program for calculating the total price of a game station, and a game. I made a program like this for just the price of a game in class, but I want to make one that does the game system as well.
View 7 Replies
ADVERTISEMENT
Dec 21, 2014
I'm working on my first video game. So far I have a few classes in the game starting with the Game class which includes a list of GameObjects (another class). There are several classes that inherit from GameObjects used to implement things like bullets, explosions, various enemy types, etc.
The game essentially iterates through the list of GameObjects to update/render them. I would like to provide access to the Game's list of GameObjects inside another class (like the Bullet class) so I can put new objects on the list. For example, when a bullet hits, I want to add an explosion to the Game's GameObject list it can be updated/rendered.
How this should be setup? I was considering adding a pointer to the Game or GameObject list to the GameObject class (and methods to access it), but I was wondering if there is a better way to set this up?
View 4 Replies
View Related
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
Apr 25, 2013
SYNOPSIS : KBJ tourist agency Sdn. Bhd wants you to write an application program to calculate the total price for their customers for a package of vacation. The following table shows the price for three destinations (transportation and accommodation) offered by the agency:
Destination TransportationAccommodation
Pulau Redang Child RM15.00
Adult RM30.00RM95 per day
Pulau Perhentian Child RM20.00
Adult RM30.00 RM100 per day
Pulau Kapas Child RM10.00
Adult RM20.00 RM120 per day
This agency company will give some discount to a group of customers with is:
a.10% discount will be given for the group that has a least 5 adults.
b.25% discount will be given for the group that has more than 5 persons (adults and children)
c.30% discount will be given for the group that has at least 15 persons.
Your application program has to display the output using this following screen layout:
KBJ TOURIST CUSTOMER INFORMATION
Customer’s name: XXXXXXXXXXXXX
Number of Children:XXXXX
Number of Adult: XXXXX
Transportation: RMXXX.XX
Accommodation: RMXXX.XX
Total price: RMXXXX.XX
This is the code i got so far but it doesn't work..:(
#include <iostream.h>
int main () {
char customerName,code,A,B,C;
int childNum,adultNum;
double rate,discount,totalPrice,a,c;
[Code] .....
View 8 Replies
View Related
Apr 13, 2014
A Bookseller makes special discount for multiple orders of a book as follows:
AMOUNT and DISCOUNT as follows.
5-9 5% 10-14 10% 15-19 15% 20+ 20%
Write a C main function to read the amount of order from the standard input and compute and print the total price of the given order after the discount. Assume that unit price of a book is 10.00$
My problem is that.When i start with this
Code:
#include<stdio.h>
#include <stdlib.h>
int main(void)
{
int number;
float TotalPrice;
printf("enter a number:");
[Code] ....
I get 0 if i enter a number between 0 and 4(0 and 4 included). I don't know where I am doing a mistake. I also want to know if i can handle this buy just if statements. or how can i do it by while and for loops ?
View 1 Replies
View Related
Dec 9, 2013
I'm writing a program to keep score of a game of bowling. Whenever I run the program, it comes up with the correct starting point, but whenever i type in the first number and click enter, the program stops running and it gives a return value of something similar to 3221225477. Here is my code. I think the problem might be that I'm not using pointers..? but I could be way off..I'm new to programming.
#include <stdio.h>
int main() {
int frame[10][3] = {{0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0,0}};
int frameOutcome[10], frameTotal[10], currentFrame = 0, totalScore = 0;
[Code] ....
View 1 Replies
View Related
Dec 14, 2014
"Write a program to play a numbers guessing game. The user thinks of a number between 1 and 100 and your program asks questions to figure out what the number is (e.g., "Is the number you are thinking of less than 50?"). Your program should be able to identify the number after asking no more than seven questions. Hint: Use < and <= opeartors and the if-else construct."
What I've managed so far, but what I have seems to be lacking
Code:
#include "../../std_lib_facilities.h"
int half(int guess);
int going_up(int i);
int main()
[Code] ....
View 4 Replies
View Related
Nov 8, 2013
I am relatively new to C programming, and I am encountering numerous issues with this program that I cant seem to figure out how to fix.
First, when the user selects the arithmetic game, I keep on getting different incorrect answers from the arithgame function. For example, when I am presented with the question 3+2=_, sometimes the function claims the answer is the first number, 3, and other times the function gives me a multiplication answer, 6. This happens in both the addition and multiplication parts (ie. the multiplication answer will either be the first number or the addition answer).
Additionally, I cant figure out why my guessing game loops forever, rather than letting me guess until I get a correct answer.
View 2 Replies
View Related
Nov 8, 2013
Need getting my program to compile.
Code:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
//prototypes
int arithGame(int max, int op);
int guessGame();
[Code] .....
View 3 Replies
View Related
Apr 5, 2014
I'm playing with a guessing game program as a personal exercise, but I'm missing a vital piece - the binary search-style code.
"Have the program initially guess 50, and have it ask the user whether the guess is high, low, or correct. If, say, the guess is low, have the next guess be halfway between 50 and 100, that is, 75. If that guess is high, let the next guess be halfway between 75 and 50, and so on."
(We're assuming that the user won't cheat.) I need the average, essentially. As in, (50 + 75) / 2 = 63.. but when I use this method of "guess = (high+low)/2, it just keeps giving me 50. I can't remember what operators I should use to increment the program's response based on the user's input. It's literally a binary search, that needs to go where those TODOs are. If low was chosen, it would have to start by being at least 51, to 100, so I'd have to set that, then find the average.
Code:
#include <stdio.h> Code: #include <ctype.h>
int main(int argc, const char * argv[]) {
int low;
int high;
int guess;
int response;
int toupper ( int );
[Code] ....
View 2 Replies
View Related
Oct 21, 2013
I am making a math game program that simple and need to have a user input a name and then that name.txt is brought up and use variables from the text to add to their score. heres my code kinda long.
#include <iostream>
#include <cmath>
#include <cctype>
#include <string>
#include <ctime>
#include <cstdlib>
[Code] ....
View 10 Replies
View Related
Apr 26, 2013
Consider a program that simulates a card game, with multiple player hands and a deck to draw from. Each hand can use an array to represent the cards it contains; sometimes it is useful to also declare an additional variable for each hand (or deck) indicating exactly how many cards are present.
1) Describe a simple function that would manipulate both the array representing a hand and the number indicating the size of the hand.
2) Describe a simple function that might be able to manipulate the array without referring to the hand size variable at all.
3) Generally, if the array was passed as a parameter to a function, how often would the hand size be included as a parameter?
View 2 Replies
View Related
Jun 6, 2013
void create_map(){
int x = 0;
int y = 0;
while (y >= 15) {
game_map[x][y].pos_x = x * tile_size;
game_map[x][y].pos_y = y * tile_size;
Objective of the code: to loop through all tiles in the game, setting their X and Y coordinates.
It just doesn't do anything at all. No error message.
View 12 Replies
View Related
Feb 11, 2013
I'm currently creating a guessing game program where the user will be asked to guess the computer generated number. Once the program is finished, at the end the user will be asked if they want to play again. If the user types "Y or Y" the program will loop and when the user types "n or N" it will not loop. Check out my code below.
#include<iostream.h>
#include<stdio.h>
#include<dos.h>
#include<stdlib.h>
#include<conio.h>
#define g gotoxy
void main(){
int a,l,b,guess,row,col,answer,num,clue=5;
[Code] ....
I can't loop this program.
View 3 Replies
View Related
Sep 26, 2013
I have to write a program that simulates a handheld gaming system. a system can have power toggled so its either on or off. when the system is on, its volume level can be raised or lowerd. a system has minimum volume level of zero and a maximum volume level of 10. a system stores games.
// simple game menu
//simulates a handheld gaming system
using namespace std;
class Game {
public:
Game(int GameNumber = 3, int volume = 10);
[Code] .....
View 1 Replies
View Related
Oct 24, 2013
I'm writing a function that is to return the price of something.. What would be the most appropriate return type for this? Like in Java it would be a double...
View 6 Replies
View Related
Feb 27, 2015
Here's my game, what do I need to learn to make a basic GUI? (Easiest way possible for now).
--NOTE, the code was a bit too long for me to post. I can add it if it is necessary. Basically all I want are 4 buttons on the main screen, one that says "Arena," "Store," "Stats," and "Exit."
There will of course be sub menus to each option, but we will get to that later.
View 1 Replies
View Related
Mar 10, 2014
How i can set if health 0 game end?
#include <Windows.h>
#include <iostream>
#include <BluetoothAPIs.h>
#include <ws2bth.h>
bool Move(int xadj, int yadj);
void LoadMap();
void DrawScreen();
[Code] ....
View 3 Replies
View Related
Feb 26, 2015
I'm having some problems figuring out 3 and 4 player games in an Uno game I'm working on. I'm not sure what specifically the problem is, however. I've tried everything I can think of; I'm at a loss for what to do next. Two player games work perfectly, which makes the nonfunctional 3 and 4 player games seem odd to me. Here is the code:
public void MoveOpponents() {
if (nextPlayer == 0) {
if (Main.dir == Direction.Clockwise) nextPlayer = 1;
else nextPlayer = numPlayers - 1;
[Code] .....
The code for the human player is in Update(), but I won't show that because it's actually quite similar to the above code.
Right now what it's doing is jumping all over the place, making opponent 2 play before opponent 1, then I play, then opponent 1 plays. Then I play again. It's really messed up.
View 6 Replies
View Related
Jan 13, 2015
Problems :
1) Is there any way so that i can use "X" and "O" char instead of 9 and 0 int.?? I also tried to use enum but was only able to print out -1 for 'X' and 0 for 'O'...
2) if player - 1 choose field 2 . and player - 2 chooses field 2 .. how can i show error and ask for another input ?
3) is there any short coding trick for int check_result(); ?
Code:
#include <iostream>
#include <string>
#include <cstdlib>
using namespace std;
[Code] ....
View 3 Replies
View Related
Nov 12, 2014
I've made an effort for three days to write this code. But, my brain has stopped now. I wrote code to find the status of the game (win, loss or tie). However, I can't determine the tie status of the game. Tie status is the problem
View 5 Replies
View Related
Nov 26, 2013
I am trying to put my Save and Load function in my game, this is what i have:
Code:
/* Save game */
void GuardarJuego() {
FILE *fsave;
char turno;
fsave=fopen("SAVE.txt", "w");
fputs(*****, fsave);
[Code] .....
My game code is this: [C] GameCode - Pastebin.com
View 8 Replies
View Related
Oct 24, 2013
I am just now in my first programming class for learning C language and I am stuck on one of my homework assignments. I am not asking you to write the code for me or anything because I want to learn by doing it myself but all I am asking for is some pointers to where I am messing up. My program is already finished for what she asked for but I am trying to do an extra credit where she wants us to have the user decide how big the gameboard is and how many mines to hide in it. Really I know that I need to use srand() and rand() but I am not sure how to use them to randomly place mines and without placing mines on top of others.
Code:
//Program 3 "Minesweeper" by Casey Samuelson
//10-17-2013
//This program will imitate the game Minesweeper.
//Agorithum
[Code]....
View 4 Replies
View Related
Feb 21, 2013
Okay so I thought I had this assignment completed properly last week. Last night I found a bug while playing the game.why won't the game end when the player guesses the correct number? The game allows you to finish using the max number of guesses even though you already guessed the correct number.
Code:
#define _CRT_SECURE_NO_DEPRECATE
#include <stdio.h>
#include <time.h>
#include <stdlib.h>
#define MAXGUESSES 6
#define MAXGAMES 20
#define MAXNUMBER 100
}
[code]....
View 9 Replies
View Related
Oct 20, 2014
I am in comp. Sci 1 at my school and I have to write a program that deals with gamer scores and the trophy they get according to expert level. For example Tom is a beginner and gets a gold medal if >=10000 a silver >= 7500 bronze if >= 5000 and no trophy if he score <5000 ! I have do this scoring for Beginner, Immediate and Expert.
Should I set up the beginning like this:
case'b':
case 'B':
if (score >= 10000 )
trophy= gold
if (score >= 7500)
trophy = silver
if (score >= 5000)
trophy= bronze
else = none
Not really sure how to go about solving this problem
View 4 Replies
View Related
Sep 2, 2014
I am making a text based rpg for school and im having troubles with it. Ineed to add an inventory into my game and im not to sure as to where or how.. this is what i got for player
#ifndef PLAYER_H
#define PLAYER_H
//console Util.h includes <iostream> , <string> and <window.h> and defines
//the NOMINMAX macro. As a result of including ConsoleUtil.h, PLayer will
// also knaow about thoes objects.
#include "ConsoleUtil.h"
[Code] ...
View 2 Replies
View Related