I am fairly new to Java programming and I am having problems with creating a program with these requirements: 1. Create a program to simulate the roll of 2 – six sided dice. 2. Test to see if the dice are equal. 3a. If they are equal print “You win! You rolled a pair. 3b. If they are not equal prompt the user if they would like to continue. 4. Use 1 to continue and 2 to end the program. 5. When the program ends print a statement one of these statements: You won after 9 rolls! Or You chose …

Member Avatar
Member Avatar
+0 forum 3

Hi Everyone!! I have a little problem in printing Character Arrays.... i have enclosed my code below. what problem actually i have is that when i type my first name and after first name (space bar) last name.. it prints only my first name. i want to type whole name after pressing space bar . and do tell me what i am doing wrong?? thanks in Advance. [CODE]#include<stdio.h> #include<conio.h> void main() { clrscr(); char name[50]; int i,j; printf("Enter Name : "); scanf("%s",name[i]); for (j=name[i]; j<=name[i]; j++) { printf("\n%s",name[i]); } getch(); } [/CODE]

Member Avatar
Member Avatar
+0 forum 6

Write a program in C/C++/Linux to find the mean and then use that mean for further calculations. Make three threads to perform different task as follows: a) The 1st Thread will find the mean. b) The 2nd Thread will take the mean from the 1st Thread and display the numbers that are greater than the mean. c) The 3rd Thread will also take the mean from the 1st Thread and display the factorial of the two numbers that are the closest to the mean. d) The Thread#2 and Thread#3 will wait until the thread#1 complete its task, and then terminate …

Member Avatar
Member Avatar
-1 forum 6

# include <iostream> using namespace std; int main() { cout << "By this program you can know about Whether a number is a or not" ; cout << "Enter a number less than 1000 :- "; int a,b,c,e,f,g,k ; cin >> a; if (a < 1000) b=a/10; k=b+2 ; c=a-(k*10); e=k/10 ; f=k-(e*10) ; g=c*c*c+e*e*e+f*f*f ; {if (g==a) cout << b <<"Yes" ; else cout << b << "No" ; } else cout << "is not" ; }

Member Avatar
Member Avatar
-1 forum 1

i'm trying to add two fractions via a function and it works. the problem is that i have to print the fraction in the main( and i have absolutly no idea how to do that) other than that the program works fine. [CODE]#include<stdio.h> #include<conio.h> #include<iostream.h> int frac(int,int,int,int); void main() { clrscr(); int a,b,c,d; cout<<"Enter fraction numbers"<<endl; cin>> a>> b>> c>> d; frac(a,b,c,d); getch(); } int frac(int a, int b, int c, int d) { int e,f; e= (a*d + c*b); f=d*b; cout<<e<<'/'<<f; return(e,f); } [/CODE] help me out please!!

Member Avatar
Member Avatar
+1 forum 5

//include files #include<stdio.h> #include<conio.h> #include<stdlib.h> #include"c:/includes.h" //stores the structures of master and index file #include"c:/function.cpp" //stores all the functions for the file primitive /* The main function input: none output:none calleed by: OS. calls: ADD_RECORD,DELETE_RECORD,MODIFY_RECORD,SEARCH_RECORD,DISPLAY_RECORD */ void main(void) { int choice; int status; int roll_no; char ch; clrscr(); printf("Enter the file name:"); scanf("%s",f_name); printf("enter the index file name:"); scanf("%s",if_name); ptr=fopen(f_name,"wb"); if(ptr==NULL) { printf("file not found"); getch(); exit(0); } iptr=fopen(if_name,"wb"); if(iptr==NULL) { printf("file not found"); getch(); exit(0); } fclose(ptr); fclose(iptr); while(1) { clrscr(); printf("\n1.add"); printf("\n2.delete"); printf("\n3.modify"); printf("\n4.search"); printf("\n5.display"); printf("\n6.exit"); printf("\nEnter the choice:"); scanf("%d",&choice); switch(choice) { case 1: status=ADD_RECORD(); if(status==1) printf("The record …

Member Avatar
Member Avatar
+0 forum 5

{ char user[]={'\0'}; char* animal_holder[12]={"Ant","Bear","Cat","D… printf("You have to guess what %c%c%c%c stands for.\n",animal_holder[a][0],animal_holde… printf("Enter your guess:"); scanf("%s",user); if(user==*animal_holder) printf("Your choice is %s",user); } What are the errors?

Member Avatar
Member Avatar
+0 forum 1

My code for the calculator is: calculator.h [CODE]#ifndef CALCULATOR_H #define CALCULATOR_H #include <QWidget> #include <QGridLayout> #include <QLineEdit> #include <QLabel> #include <QPushButton> #include <QLCDNumber> #include <QString> #include <QMessageBox> #include <QErrorMessage> class Calculator : public QWidget { Q_OBJECT public: //constructor Calculator(); public slots: //function to add the two numbers that the user inputs void addition(); //function to subtract the two numbers that the user inputs void subtraction(); //function to multiply the two numbers that the user inputs void multiply(); //function to divide the two numbers that the user inputs void division(); //function to clear widgets void clearFields(); //function to close window void …

Member Avatar
Member Avatar
-1 forum 1

[CODE]#include<string.h> #define MAX 15 #define true 1 #define false 0 /*Structure Decvlaration*/ typedef struct { char data[MAX]; char top; }STK; /*Function Declarations*/ void input(char str[]); void intopre(char str1[],char pre[]); void intopost(char str1[],char post[]); int isoperand(char sym); int prcd(char sym); void push(STK *s1,char elem); int pop(STK *s1); int empty(STK *s2); int full(STK *s2); void dis(char str[]); void main() { STK s; int cs,ans; char str[MAX],pre[MAX],post[MAX]; clrscr(); do /*Using Do-while Loop*/ { clrscr(); printf(" -----Program for Expressions-----"); printf(" Input The String:"); printf(" MENU: "); printf("1.Infix to Prefix "); printf("2.Infix to Postfix"); printf(" 3.Exit"); cs=getche(); switch(cs) /*Using Switch Case*/ { case 1: intopre(str,pre); …

Member Avatar
Member Avatar
+0 forum 2

Hi i saw a post about this program already. im new to c++ and im lost... completely lost... im not even sure im posting this in the right place. anyways. the program i got is working correctly until i make it an OOP which is what my teacher wants us to do for every program we do. this is what i have so far. [CODE]// Menu Chooser.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include <string> #include<iostream> using namespace std; class MenuChooser { private: public: MenuChooser(){ int main() { cout << "Difficulty Levels\n\n"; cout << …

Member Avatar
Member Avatar
+0 forum 7

I'm reading a big csv file into a data structure defined as such: [CODE]struct PriceInfo { double Open; double High; double Low; double Close; unsigned int Volume; unsigned int Time; std::string Date; };[/CODE] So somewhere in my main function, I have this line: // read contents of datafile by overloading the input operator into a vector of type <PriceInfo> called prices [CODE]while (! dataFile.eof()) { dataFile >> prices }[/CODE] The csv file is comma delineated, so I use an extra function to do the parsing, beyond a template and the overloading function (with the following header std::istream& operator>>(std::istream& istream, PriceInfo& …

Member Avatar
Member Avatar
+0 forum 11

Hi, we have this school activity that is rush for tonight. I would really appreciate if somebody will help me. It would really mean a lot to me. So here is the problem that were tasked to us to create a C++ program. Problem: Write a C++ program to perform addition of two hexadecimal numerals each with up to 10 digits. If the result of the addition is more than 10 digits long, then simply give the output message “*********Overflow Error *********** ” and not the results in addition. Use arrays to store hexadecimal numerals as arrays of characters. Include …

Member Avatar
Member Avatar
+0 forum 3

[CODE]void printer(char x) { int d, b, z; for(z=x; z>=1; z--) { for(b=z; b<=x-1; b++) printf(" "); for(d=z; d>=1; d--) printf("%d ", d); printf("\n"); } }[/CODE] that's my code which is supposed to print 4 3 2 1 4 3 2 4 3 4 when input is 4. however, it prints as 4 3 2 1 3 2 1 2 1 1

Member Avatar
Member Avatar
+0 forum 3

its my code pleas tell me y error occur in it. impex.h file [CODE]#ifndef IMPEX1_H #define IMPEX1_H enum shapetype {Point=1,Polyline=3,Polygon=5}; struct pointD { double x; double y; }; struct item { int id; list<pointD>coordinates; shapetype type; }; class impex { public: impex(); void savekml(list<item>); private: }; #endif .cpp file #include<iostream.h> #include<conio.h> #include"impex.h" impex::impex() {} void impex::savekml(list<item> b) { <?xml version="1.0" encoding="UTF-8"?> <kml xmlns="http://www.opengis.net/kml/2.2"> <placemark> <name>obj2.type</name> <Point> <coordinates>obj2.coordinates.x,obj2.coordinates.y</coordinates> </Point> </placemark> </kml> } main #include <cstdlib> #include <iostream> #include "impex.h" using namespace std; int main(int argc, char *argv[]) { system("PAUSE"); return EXIT_SUCCESS; }[/CODE] why list is undeclare???help me plz

Member Avatar
Member Avatar
+0 forum 2

Which of the following are valid function prototypes? x one(int a, int b); int thisone(char x); char another(int a, b); double yetanother; void thelastone(); void (function1) void; void function2(void) void function3(n, x, a, b); x void finction4(int n, float, char c); x void function5(int, a, int n); Which of the following lines contain errors? int a, b(2); x float a23b[99], 1xy[66]; void city[36], town[45]; double temperature[-100]; long phone[200]; int a = {11,22}, b[33]; float c[3] = {11,22,33,44}; double d(4) = (11,22,33,44); d[4] = {11,22,33,44}; x int a[3]/11,22,33/; Given this function prototype int calc_area(int*, int*); and the following variable declarations ( …

Member Avatar
Member Avatar
+0 forum 9

[CODE]char main()/*Start of the function main???*/ { char choice1; char choices = 'y'; while(choices == 'y' && choices != 'n'){/*while loop initialization*/ print(); getchar(); scanf("%c",&choice1); printf("%c",choice1); switch(choice1){/*Switch case statement,,,*/ case 'a': case 'A': addContact(); break; case 'f': case 'F': search(contacts); break; case 'v': case 'V': list(); break; case 'e': case 'E': edit(contacts); break; case 'd': case 'D': list(); printf("Which contact do you to delete?\n"); deleteCont(contacts); default: printf("You pressed 1 EXIT status!!!!\n"); }/*end of switch case...*/ printf("\nIs there anything you want to add?Y/N");/*while loop update!!!*/ getchar(); scanf("%c",&choices); } }/*end of function main()*/[/CODE]

Member Avatar
Member Avatar
+0 forum 11

hey guys... i wanted to know how to make multiple conditions such that each condition has arange of values...i have written the following code but doesnt work help me quick plz. It is aPIC program for monitoring the ADC value and sending to LCD [CODE]if(ADRESL==0x00) {lcddata('O'); DELAY(2); lcddata('F'); DELAY(2); lcddata('F'); DELAY(2); } else if(0x00<ADRESL<0x70) { lcddata('S'); DELAY(2); } else { lcddata('M'); DELAY(2); }[/CODE]

Member Avatar
Member Avatar
+0 forum 16

please help me fix these problem,,,, when i'm running the program it exits emediately [CODE]main()/*Start of the function main???*/ { do{/*do while loop initialization*/ print(); scanf("%c",&choice1); switch(choice1){ case 'A': case 'a': addContact(); break; case 'F': case 'f': search(contacts); break; case 'v': case 'V': list(); break; case 'e': case 'E': edit(contacts); break; default: print(); } printf(""); printf("Do you want to enter another contact?Y/N\n");/*condition question of loop*/ scanf("%c",&choice2); if (choice2 == 'y' || 'Y'){ choice2 == 'y'; }else{ break; } }while(choice2 == 'Y' || choice2 == 'y'); }/*end of function main()*/[/CODE]

Member Avatar
Member Avatar
+0 forum 4

Hi can someone help in in understanding the following code esp the "?".I cant understand how the output 9:10:5 as obtained. Thank You. The code is as followed: [CODE]#include <iostream> using namespace std; int main() { short hour =9, minute =10, second =5; cout << (hour <10 ? "0":"" )<<hour<<":" << (minute <10 ? "0":"" )<<minute<<":" << (second <10 ? "0":"" )<<second<<endl; cin.get(); return 0; }[/CODE]

Member Avatar
Member Avatar
+0 forum 3

I have set up the following structs: [CODE]typedef struct lineList { int lineNum; struct lineList* Next; }*Line; typedef struct DictionaryList { char* word; Line lines; struct dictionaryList* Next; }*Dictionary; and then I have defined: Dictionary head = NULL; /*is a pointer to head of dictionary list */ Dictionary node = (Dictionary)malloc(sizeof(struct DictionaryList)); ... node->Next = head;[/CODE] and I get the folowings error: assignment from incompatible pointer type I don't understand why both head and node are the same type: Dictionary.

Member Avatar
Member Avatar
+0 forum 2

[code]#include <stdio.h> #include <stdlib.h> int main() { int numbers[10] = {12,33,51,1,-1,97,7,23,0,-99}; sort(numbers,10); display(numbers,10); return 0; } void sort(int *numbers, int size) { /* Hop you could help me provide codes to sort the numbers. after calling this function, the numbers array in main should be sorted. hint: use the size for looping */ } void display(int *numbers, int size) { /* this will print the array of integers that has been called. */ } [/code] pls help me, i am still learning..:( hop you can help me..tnx :)

Member Avatar
Member Avatar
+0 forum 13

[CODE]// Program Dictionary // Proogram that uses linked list to maintain a dictionary #include <iostream.h> #include <stdlib.h> #include <stdio.h> #include <conio.h> #include <string.h> #include <ctype.h> class dict { private : struct node { char data[20] ; char m[100] ; int mcount ; struct node * link ; } *dic[22] ; public : dict( ) ; void store (); int search ( char * ); void show( ) ; void deldic( ) ; } ; // initialises data member dict :: dict() { for ( int i = 0 ; i < 22 ; i++ ) dic[i] = NULL ; } …

Member Avatar
Member Avatar
+0 forum 7

Hi please find this simple program, not sure why realloc is not working and its causing memory leak. But if calloc and malloc is used with little changes it works fine. [CODE]#include "string.h" #include "stdio.h" #include "stdlib.h" char *mystrcat(char*, char*); void main(void){ char str1[] = "quick brown fox"; char str2[] = "Jumps over the lazy dog"; printf("%s", strcat(str1, str2)); } char *mystrcat(char* str1, char* str2){ char *newstr ; int i = strlen(str1); int newSize = sizeof(char) * (strlen(str1)+strlen(str2)+1); // new size of array if((str1 = (char *)realloc((void *)str1, newSize)) == NULL){ fprintf(stderr, "Error: Could not allocate desired size"); } //str1 …

Member Avatar
Member Avatar
+0 forum 1

[code]#include <iostream> #include <cassert>//what is the use of this??? #include <algorithm>//how to convert in turbo c++ and what is the use this??? #include <vector>//is this array in turbo c++??? using namespace std; int main() { bool result;// what is the use of this?? string s("abcde"); string s2("aeiou"); vector<char> vector1(s.begin(), s.end());// how to convert this in turbo c++ vector<char> vector2(s2.begin(), s2.end());//how to convert this in turbo c++ vector<char> setDifference;//how t convert this in turbo c++ set_symmetric_difference(vector1.begin(),vector1.end(),vector2.begin(), vector2.end(),back_inserter(setDifference));//how to convert this in turbo c++ for(int i=0;i<setDifference.size();i++){ cout << setDifference[i]; } return 0; }[/code]

Member Avatar
Member Avatar
+0 forum 6

can any one help me in solving a question posted by friend..... i tried to google but i didnt find the accurate answer for my question.. i wish to 'print 1 to n' without using loops and recursion help me please.. thanks in advance

Member Avatar
Member Avatar
+0 forum 31

[code]#include<stdio.h> #include<conio.h> void main() { char gender,Mar_stat; int age; clrscr(); printf("Enter your Marital Status "ma" or "um":\n"); scanf("%c",&Mar_stat); if (Mar_stat == 'ma') { printf("Enter your Gender And Age :\n"); scanf("%c %d",&gender,&age); if (gender=='M' && age >= 30) { printf("You are Insured"); } else { printf("Sorry"); } getch(); } } [/code] What i am doing wrong in this program , i need a program to ask me If i am married, If married then ask my gender then age , if gender Male or Female and age minimum 30 or 25 respectively then printf("Your are insured "); but it says nothing........ …

Member Avatar
Member Avatar
+0 forum 10

[code] void generalboard(); void inputuser(int*pt1, int*pt2,int*pt3); void checkwins1d(int*A,int*B, char C[][3][3]); void checkwinsup(int*A,int*B,char C[][3][3]); void checkwins3D(int*A,int*B,char C[][3][3]); void inputcomputer(int*pt1,int*pt2,int*pt3,char A[][3][3]); void score (int a, int b); void displayboard(int a, int b, int c, int i, int j, int k, char board [][3][3]); int main () { int i,j,k,a,b,c,computerscore=0,userscore=0,counter=0; char board[3][3][3]; generalboard(); inputuser(&i,&j,&k); inputcomputer(&a,&b,&c,board[3][3][3]); displayboard(a,b,c,i,j,k,board[3][3][3]); while (counter<=27){ inputuser(&i,&j,&k); counter++; inputcomputer(&a,&b,&c, board[3][3][3]); counter++; displayboard(a,b,c,i,j,k,board[3][3][3]); checkwins1d(&userscore,&computerscore,board[3][3][3]); checkwinsup(&userscore,&computerscore, board[3][3][3]); checkwins3D(&userscore,&computerscore,board[3][3][3]); score(computerscore, userscore); } if (computerscore> userscore) printf("Computer is the winner.\n"); else if (computerscore<userscore) printf ("Congrats, you won!\n"); else printf("it is a draw.\n"); return 0; } This is a 3D TTT game program... for all the …

Member Avatar
Member Avatar
-1 forum 6

I am pretty new to programming. I am trying to write a code that counts the occurrence of a word, lists it and also the number of times it appears in a given text. This is what I have, but I can not get it to print the word once and count it if it occurs more than once. Please, any help would be appreciated! [code]// This program counts word occurence in a given text #include <iostream> #include <iomanip> using namespace std; class tokenizer { char * src_ptr; char * c_token; char * token_start_ptr; public: tokenizer(const char * in_str){ // …

Member Avatar
Member Avatar
+0 forum 4

this is what i have so far, i need to combine 2 c strings, print them backwards and figure out whether they are a palindrome or not. (the for loop is where i stopped, it could be wrong) [CODE]#include<iostream> #include<cstring> using namespace std; int main( ) { char s1[15], s2[8]; int length1; int count = 0; cout << "Now I let you enter two strings \n"; cout << "Enter the first string, then the second \n"; // Another way to initialize the two strings cin >> s1 >> s2; strcat(s1, s2); for(int i=0, i < length, i++) { count++; system("pause"); …

Member Avatar
Member Avatar
+0 forum 6

I think I may have bitten off more than I can chew with this. I'm writing a program that will figure out the last position standing by continuously counting the positions using prime numbers till only one is left. [url]http://acm.uva.es/p/v100/10015.html[/url] is a link to the original problem. the code I have so far is below it's not very good and has a lot of extra crap. If any of you has an idea on how to get it working I'd really appreciate it! [CODE]#include <iostream> using namespace std; //------------------------- // Constants //------------------------- int MAX_PERSONNEL = 100; // capacity of the …

Member Avatar
Member Avatar
+0 forum 1

The End.