Max and min come out wrong, they go to 0's when it outputs ? How do I fix, any solutions?? #include <iostream> #include <iomanip> #include <string> using namespace std; int main() { int x, y, z; int total; float average; //Read data into x, y, z void ReadData(int & x, int & y, int & z); { { cout << "Enter three integer numbers: "; cin >> x >> y >> z; } //Comput total of x, y, z int total; int ComputSum(int a, int b, int c); //Compute average of x, y, z void ComputeAverage(int x, int y, int …

Member Avatar
Member Avatar
+0 forum 2

Good Day guys, I wanted to make a multiplication table but it seems not that easy for a newbie like me. Mind taking your time and see what I am missing in my code? It would be a great help. Here's the code: #include<iostream> #include<conio.h> using namespace std; void initArray(int arg1[50][50], int r, int c) { int val=1; for(int row=0; row<r; row++) { for(int col=0; col<c; col++) { arg1[row][col]=val; val++; } } } void mulTable(int arg1[50][50], int r, int c) { for(int row=0; row<r; row++) { int mul=0; for(int col=0; col<c; col++) { mul = mul * arg1[row][col]; cout << …

Member Avatar
Member Avatar
+0 forum 2

edges.txt is used.it is the input adjacency list. 1 3 1 5 2 3 2 6 4 5 5 6 #include<stdio.h> #include<stdlib.h> #include<conio.h> int **adjL; int v,*arr; void dfs(int **adjL) { int j,i=0,temp,dfslabel=1,s=0,k=0,top=0; int stack[v]; int *flag; flag=(int*)calloc(v+1,sizeof(int)); for(i=0;i<=v;i++) flag[i]=0; stack[++top]=1; flag[1]=3; stack[top]=1; while(1) { if(i==arr[stack[top]-1]) { printf("examination of %d is complete",stack[top]); top--; } if(top==-1) break; if(flag[adjL[stack[top]-1][i]]==0) { temp=adjL[stack[top]-1][i]; stack[top++]=temp; i=0; flag[temp]=stack[top-1]; printf("\nDFS label:%d ,current node=%d,linkprocessed %d to %d (tree edge)",dfslabel,stack[top-1],stack[top-1],temp); dfslabel++; } else { if(flag[adjL[stack[top]-1][i]]==stack[top-1]) printf("\nbackedge"); else printf("\ncycle"); i++; } } } int main() { FILE *fp; int *index; v=-1; int num1,num2; int i=0,j; fp=fopen("edges.txt","r"); while(fscanf(fp,"%d %d",&num1,&num2)!=EOF) { if(num1>v) …

Member Avatar
Member Avatar
+0 forum 3

public class homework8_2 public static void main(String [] args) { Scanner keyboard = new Scanner(System.in); int selections = 0; DecimalFormat formatter = new DecimalFormat("#0.0000"); do { showMenu(); selections = keyboard.nextInt(); System.out.println("please input the amount of meters"); double meters = keyboard.nextDouble(); if (selections == 1) { double kilometers; kilometers = showKilometers(meters); System.out.println("Kilometers = " + kilometers); } else if (selections == 2) { double inches = 0; inches = showInches(meters); System.out.println("inches = " + inches); } else if (selections == 3) { double feet = 0; feet = showFeet(meters); System.out.println("Feets = " + feet); } }while (selections != 4); } public …

Member Avatar
Member Avatar
+0 forum 6

I'm almost finished coding the last of my C program on stock inventory but in the last two functions (one being my main function and the other a void function) the compiler gives an error stating that there a Parse Issue and that an expected identifier or "(" is missing in main.c .. I've already opened and closed my functions with '{, }' and this errpr doesnt exist in my other functions any idea on what the error could be?

Member Avatar
Member Avatar
+0 forum 9

why void functions cannot contain return type?

Member Avatar
Member Avatar
+0 forum 2

Hi, I kind of need help with my homework. I already have a code but it doesn't seem to work. I'm confused about the parameters I put. I don't know which part I actually messed up. I don't know what else to do. Thank you so much in advance for your help :] [CODE]#include <iostream> #include <string> #include <fstream> using namespace std; //Function Prototypes float gPACalculation(char cGrade); string honorsDistinction(float fGPA); void summaryInformation(float fGPA, string sHonorsDistinction); //Declare Constants const int SENTINEL = 0; int main () { //Declare Variables ifstream inFile; //input file ofstream outFile; //output file char cGrade =' '; …

Member Avatar
Member Avatar
+0 forum 8

Hello, main.cpp #include <iostream> #include <string> #include <sstream> #include <cstdlib> #include "Triangle.h" using namespace std; int main() { Triangle myTriangle; int side1; double side2; double side3; string input; char ch; do { cout << "Triangle ADT Program" << endl; cout << "Enter the side lengths :" << endl; cout << "---------------------" << endl; cout << "Enter length 1> "; getline(cin, input); side1 = myTriangle.setside1(side1); cout << "Enter length 2> "; getline(cin, input); side2 = myTriangle.setside2(side2); cout << "Enter length 3> "; getline(cin, input); side3 = myTriangle.setside3(side3); cout << "---------------------" << endl; cout << "This triangle is a "; myTriangle.getTriangle(); cout …

Member Avatar
Member Avatar
+0 forum 4

Hi, I am trying to read a value which is in a class (in a public void) in anothe class and I couldn't do that, so please can someone reply me and tell me how to do that using these code. public class CDB { public static String main(String[] args) { String animal_name="cat"; }} public class conn extends CDB { //What code should enter here to read the value(animal_name) }

Member Avatar
Member Avatar
+0 forum 1

**Hello i am a noob when it comes to java so sorry if its obvious but the code below is giving me a error when i try to compile it, the error is: Exception in thread "main" java.lang.Error: Unresolved compilation problem: at goodcalculator.main(goodcalculator.java:127). Can anyone help me? ** CODE: import java.awt.*; import java.awt.event.*; import javax.swing.*; class goodcalculator extends JFrame { JButton add, subtract, multiply, divide; JtextField num1, num2; JLabel result, enter1, enter2; public goodcalculator() { setLayout (new GridBagLayout()); GridBagConstraints c =new GridBagConstraints(); enter1 = new JLabel("1st: "); c.fill = GridBagConstraints.HORIZONTAL; c.gridx = 0; c.gridy = 0; add(enter1, c); num1 = …

Member Avatar
Member Avatar
+0 forum 3

This program ask user which arithmetic operation they want to play with then generates a random equation and lets the user answer it. When the user stop playing the game the program calculates the number of correct and answers and wrong answers. I need some help because the program crashes when doing divisions. [CODE]#include <iostream> #include <fstream> #include <string> #include <cstring> #include <cmath> #include <cstdlib> #include <iomanip> //include header file #include "lab_17_head.h" using namespace std; int main( ) { //variable declaration int number1, number2; //vars to store int values double intResult, doubleResult, result; //vars to store the result char action; …

Member Avatar
Member Avatar
+0 forum 19

Hi everyone! This is the code that I have written in order to print a tic-tac-toe board. For example, if input was this: 1 2 0 1 1 2 0 2 0 The board would be this: X . O X X . O . O However, I don't know how to use void instead without changing the behaviour of the program. I have tried adding the following: void readBoard(int board[SIZE][SIZE]); void printBoard(int board[SIZE][SIZE]); but I know I have done it wrong //WITHOUT VOID #include <stdio.h> int main (int argc, char *argv[]) { int ROW[3] [3]; int i, j; printf("Please …

Member Avatar
Member Avatar
+0 forum 2

I want to create a struct array and get the max number of books written by particular author...The problem is that i can't get the number. I am not finished up yet with the code,but i don't know why i am not getting anything when calling the Max function.Please advise! I had recently started learning C++,so bear with me! [CODE] #include <iostream> #include <cstring> using namespace std; struct book { char author[50]; int number; }; void input_info(book *m,int n) { for (int i=0;i<n;i++) { cin.ignore(); cout<<"Enter author's name: " << endl; cin.getline(m[i].author,50); cout<<"Enter the number of books written:" << endl; …

Member Avatar
Member Avatar
+0 forum 2

here is the details I got: 1. Create a class called 'GuessMyNumber'. The constructor should chose a random number between 1 and 100. There should be a method 'guess(int guess)' that returns -1 if the guess is too low, 0 if the guess is correct, and 1 if the guess is too high. 2. Create a class called 'HalvsiesGuesser' that overrides the guess method. It should take the full range of numbers possible and guess the middle one each time. (for example, it's first guess should be 50, if that's too high, the next guess should be 25....) Reset should …

Member Avatar
Member Avatar
+0 forum 1

Why is this? [CODE] int kitty(GtkWidget* widget, float* foo) { if(*foo != .5f) std::cout << "this usually occurs" << std::endl; } int otherFunc(void) { float foo = .5f; //assume widget has been created g_signal_connect(G_OBJECT(widget), "clicked", G_CALLBACK(kitty), (gpointer)&foo); }[/CODE]

Member Avatar
Member Avatar
+0 forum 1

I'm new to C++, and I've been picking it up really well, but when it came to making my own function, I hit a problem. I've looked and I cant find the problem, its probably something really stupid but I cant find it. Heres the code, its really simple. I'll put the code in bold. From the top: [CODE] # include <iostream> using namespace std; int main() { cout << "Hello!\n"; testFunction (); cout << "Your back!\n"; char f; cin >> f; return 0; } void testFunction () { cout << "Hello 2!\n"; } [/CODE] I know its really simple …

Member Avatar
Member Avatar
+0 forum 5

[CODE]import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Calendar; import java.util.GregorianCalendar; public class CheckIn{ Date today; void getArrivalDate() { DateFormat df = new SimpleDateFormat("dd/MM/yyyy"); try { System.out.print("Enter Date in dd/mm/yyyy format: "); String d = Keyboard.readString(); today = df.parse(d); df.format(today); } catch (ParseException e) { e.printStackTrace(); } } void getDepartureDate(){ Calendar ca1 = Calendar.getInstance(); ca1.setTime(today); System.out.print("How many nights do you want to stay? "); int nights = Keyboard.readInt(); ca1.add(Calendar.DATE, nights); System.out.println("Departure Date: " + ca1.get(Calendar.DATE) + "/" + (ca1.get(Calendar.MONTH) + 1) + "/" + ca1.get(Calendar.YEAR) + "\n"); } } [/CODE] I've made these two methods and they are working …

Member Avatar
Member Avatar
+0 forum 7

Hello everybody I have a problem with my code. On two lines (14 & 17) I get this error: cannot return a value from method whose result type is void. But I don't have add void to my class. Thanks in advance. Greets MeandJava Here's my code: [CODE]package oop_po2; import java.awt.Image; import java.net.URL; import javax.swing.Icon; import javax.swing.ImageIcon; public class OOP_PO2_Test { public ImageIcon(String filename){ java.net.URL imgURL = ImageIcon.class.getResource(filename); if (imgURL != null) { return new ImageIcon(imgURL); } else { System.err.println("Couldn't find file: " + filename); return null; } } public Image getImage(String path){ Image image = null; // TODO OOP_PO2_A1: …

Member Avatar
Member Avatar
+0 forum 5

How do i call back a variable in void method into the main method?? [CODE]public void multiply (int x) { Vector3 v3 = new Vector3(num1*x,num2*x,num3*x); }[/CODE]

Member Avatar
Member Avatar
+0 forum 6

Well, I've been Googling for at least 30 minutes, and looking through past posts about this, but just can't seem to find an answer that works. Basically, I've got a component class that has a single method I'm trying to test out. The entity class has a private array of these components (actually, it's an array of void*, but I cast to the appropriate type when getting the component from the array). So when I call the method it looks like this: [code]((Component*)myEntity.getComponent(Base))->testFunction();[/code] This is the error I'm getting: 1>main.obj : error LNK2019: unresolved external symbol "public: __thiscall GE::Component::Component(void)" (??0Component@GE@@QAE@XZ) …

Member Avatar
Member Avatar
+0 forum 1

hi how is it possible to return an array from this: private void btnResult_Click(object sender, EventArgs e) { ArrayList arlist = new ArrayList(); arlist.Add(examResults); return arlist; } Many Thanks

Member Avatar
Member Avatar
+0 forum 1

For a function protoype header can one be double while the other one is void? I'm trying to make the void displayPayment function work, but am a little lost. Should I turn the carPrice, Rebate, ect.. into void functions in the prototype, or can they work without doing that? Thanks for your time, Michelle [CODE=cpp]#include <iostream> #include <iomanip> #include <cmath> using namespace std; //function prototype double calcPayment (double, double, int); void displayPayment (double, double&); int main() { //declare variables double carPrice = 0.0; double rebate = 0.0; double creditRate = 0.0; double dealerRate = 0.0; int term = 0; double …

Member Avatar
Member Avatar
+0 forum 2

I am trying to make a form using html and JSP, get the data and save them in an XML file. I use also Tomcat 1.6 as server. For generating the XML I am using the XStream library. I have a Customer.java class with get and set methods for a message and an email. Then I have a GenerateXml.java file which creates a Customer object, get the data and add them in an XML file: [code=Java]Customer customer = new Customer(); customer.getMessage(); customer.getEmail(); XStream xs = new XStream(); try { FileOutputStream fs = new FileOutputStream("C:\\customers.txt"); xs.toXML(customer, fs); } catch (FileNotFoundException e1) …

Member Avatar
Member Avatar
+0 forum 1

Okay, I'm making a shooter game, and all my weapons are differnt userdefined objects; ie. the flamethrower works differently then the gun, however, I'm calling some functions in my "main", an example of this would be; [CODE] /* <Init> */ MachineGunClass *CurrentWeapon; MachineGunClass *MachineGun; MachineGun = new MachineGunClass(); CurrentWeapon = MachineGun; /* </Init> */ /* <Usage> */ /* Lots of code */ CurrentWeapon->Shoot(); /*More code */ /* </Usage> */ [/CODE] So this works as it should, however let's say I wanted to use my flamethrower, to change to that weapon I would call the following; [CODE] FlameThrowerClass *FlameThrower; FlameThrower = …

Member Avatar
Member Avatar
+0 forum 8

I need to finish this program, but i have no idea how to! please help me figure this out. [code] #include <iostream> #include <fstream> using namespace std; void printShips(char [15][15]); void fire(int row, int col, char ocean[15][15], char &result, char &ship); struct counter { int B, C, D, F, T, S; }; int main() { ifstream myin; char ocean[15][15]; char battle[15][15]; int i,j; char trash; int missles = 30; bool won = false; int row, col; char result, ship; counter counters; //Initialize the counters counters.B = 4; counters.C = 5; counters.D = 3; counters.F = 2; counters.S = 3; counters.T …

Member Avatar
Member Avatar
+0 forum 11

The End.