c++ prog 0 Light Poster

hi, can anyone help me with my codes. I can't find the right solution for getting the average of the sum. For example, my first number is 1 and the second is 10. It will get the sum of either all the even nos there or the odd nos there. And then it will get the average of it. Pls help me. tnx.

TAKEHOME.COB                            Wed Dec 03 17:08:51 2008    Page   1
 line number source line   Microsoft COBOL                       Version 2.20

   1          IDENTIFICATION DIVISION.
   2          PROGRAM-ID.  Iteration-If.
   3          AUTHOR.  Michael Coughlan.
   4    
   5          ENVIRONMENT DIVISION.
   6    
   7          DATA DIVISION.
   8    
   9          WORKING-STORAGE SECTION.
  10          01  Num1           PIC 99  VALUE ZEROS.
  11          01  Num2           PIC 99  VALUE ZEROS.
  12          01  Result         PIC 999 VALUE ZEROS.
  13          01  Sum-Nos        PIC 999 VALUE ZEROS.
  14          01  Prod-Nos       PIC 999 VALUE 1.
  15          01  Ave-Nos        PIC 99.99 VALUE ZEROS.
  16          01  Counter        PIC 99  VALUE ZEROS.
  17          01  Operator       PIC X  VALUE SPACE.
  18          01  Answer         PIC X  VALUE SPACE.
  19          01  CHECKEVEN     PIC 99   VALUE ZEROS.
  20          01  CHECKODD      PIC 99   VALUE ZEROS.
  21    
  22          PROCEDURE DIVISION.
  23    
  24          Main.
  25             DISPLAY "Enter First Integer: ".
  26             ACCEPT Num1.
  27             DISPLAY "Enter Second Integer: ".
  28             ACCEPT Num2.
  29             DISPLAY "Choose 0/E/A: ".
  30             ACCEPT Answer.
  31             IF Answer = "O"
  32              PERFORM Odd
  33             ELSE
  34             IF Answer = "E"
  35              PERFORM Even
  36             ELSE
  37             IF Answer = "A"
  38              PERFORM Gabos
  39             ELSE
  40              DISPLAY "Invalid Input!".
  41    
  42          Gabos.
  43             PERFORM …
c++ prog 0 Light Poster
/*

 */

package alejo_a1;


import java.util.Scanner;
public class java {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        double n;
        Scanner input = new Scanner(System.in);
        
        System.out.print("Enter integer to be solved: ");
        n = input.nextDouble();
        //for (double i=0; i >= 10; i++)
        //if (n >= 10)
        //{
        //{
          //  for(int i = 1; i >=10; i++)
            //{
           // i = n;
        System.out.println("The Square of " + n + "= " + Square(n));
        System.out.println("The Square Root of " + n + "= " + SquareRoot(n));
        System.out.println("The Cube of " + n + "= " + Cube(n));
        System.out.println("The Fourth Root of " + n + "= " + FourthRoot(n));
        //}
            //}
        //}
    }
    
   static double Square( double Squ)
    {
       double result = 0;
       int i =0;
       result= Math.pow(Squ,2);
      // for (;i >= 10; i++)
   
      return result;
       
    }
   
   static double SquareRoot( double TwoRoot)
   {
       int i =0;
       double result2 = 0;
       result2 = Math.pow(TwoRoot, (1/2));
       while(i >= 10)
       {
       
       System.out.println("Square Root of" + TwoRoot + "= " + result2);
       i++;
       }
       return result2;
       
   }
   
   static double Cube( double CubeX)
   {
       int i =0;
   double result3 = 0;
   result3 = Math.pow(CubeX, 3);
  
       do{
       
       
       //System.out.println("Cube of" + CubeX + "= " + result3);
       }while(i >= 10);
       return result3;
   }
   
   static double FourthRoot( double Fourth)
   {
       int i = 0;
       double result4 =0;
       result4 = Math.pow(Fourth, 0.25);
       for (; i >= 10; i++)
       {
       
       System.out.println(" Fourth Root of" + Fourth + "= " + result4);
       }
       return result4;
   }

}

it's a bit messy

c++ prog 0 Light Poster

hi, we have a simple program here that states like this:

input >= 10

ex: 12

1	Square		Sqrt		Cube		Fouthroot
2	-		-		-		-	
3	-		-		-		-
4
5
6
7
8
9
10
11
12

i made the code already but I still can't find a solution the solutions from 1 to 11.. my code only displays the results for the 12... I know this can be solved pretty easily by some loops, but for a strange reason,I can't find the right algorithm! lol! i just need an algorithm and just leave the programming to me..tnx

c++ prog 0 Light Poster

I promise this will be my last question..lol..
how can I change the path in the control panel?

c++ prog 0 Light Poster

yup..I downloaded the link you provided..
actually I have Java(TM) 6 Update 10
& Java(TM) 6 Update 7

what else should I download?
I downloaded already a NetBeans Installer

c++ prog 0 Light Poster

yeah...I didn't noticed there were many typographical errors..lol..so.. it would be like this:

h = input.nextDouble();

and also which one should I download? I tried many updates now but NetBeans still seerches for a full JDK..that's why I can't proceed..I downloaded (netbeans-6.1-ml-javase-windows)..is this enough?will this work if I downloaded the right JDK?

c++ prog 0 Light Poster

hi we have a programming assignment which computes the volume of a barrel. I don't have a compiler yet and java is not yet recognized by my computer yet because I haven't downloaded any JDK yet because I don't know which one to download...Here's my code so far...Please just review my codes because I can't test them and this is my first programming ass in java..so i'm still a newbie..

import java.util.Scanner;

public class A1{
	public static void main(String args[])
	{
	double h, r1, r2; byte b;
	
	Sanner input = new Scanner(System.in);
	System.out.println("Enter r1 & r2");
	b = input.nextByte();
	r1 = input.nextDouble();
	r2 = input.nextDouble();

	System.out.print("Volume Of the barrel is= "
	+ (h*Math.Pi*(((2*r1)*(2*r1)) + ((r2)*(r2))) / 3));
	}
}
c++ prog 0 Light Poster

you're hopeless...show some effort before posting threads here

c++ prog 0 Light Poster

hmmm..im almost there!!tnx!! do you know how to read & write???

c++ prog 0 Light Poster

yah...that's what my problem is...I cant send & receive...how can I?

c++ prog 0 Light Poster

hi, my problem is about socket programming. My code below only connects the client to the server, and it works just fine. However, I should create a 2player game which of course require the interaction of the 1st and 2nd player. The problem here is that they really don't interact with each other, it is as if the terminal for the client side is a separate program from the terminal for the server side(sorry if I can't explain it clearly..lol) yeah, the client connected successfully, but they don't interact..pls I really need this code or else I'll fail my subject..tnx a lot!

Client-side

#include <iostream>
#include <iomanip>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h> 
#include <stdio.h>
#include <termios.h>
#include <unistd.h>


using namespace std;

const int totchan=7;

void error(char *msg)
{
    perror(msg);
    exit(0);
}
 
int main(int argc, char *argv[])
{
    int sockfd, portno, n, input;
    struct sockaddr_in serv_addr;
    struct hostent *server;

    char buffer[256];
    if (argc < 3) {
       fprintf(stderr,"usage %s hostname port\n", argv[0]);
       exit(0);
    }
    portno = atoi(argv[2]);
    sockfd = socket(AF_INET, SOCK_STREAM, 0);
    if (sockfd < 0) 
        error("ERROR opening socket");
    server = gethostbyname(argv[1]);
    if (server == NULL) {
        fprintf(stderr,"ERROR, no such host\n");
        exit(0);
    }
    bzero((char *) &serv_addr, sizeof(serv_addr));
    serv_addr.sin_family = AF_INET;
    bcopy((char *)server->h_addr, 
         (char *)&serv_addr.sin_addr.s_addr,
         server->h_length);
    serv_addr.sin_port = htons(portno);
    
    if (connect(sockfd,(struct sockaddr *)&serv_addr,sizeof(serv_addr)) < 0)  
        error("ERROR connecting");


cout<<"+--------------------------------------+"<<endl;
    cout<<"|   This is a shooting game. You must  |"<<endl;
    cout<<"|   type as many as you can, the       |"<<endl;
    cout<<"|   letters on the screen that you can |"<<endl;
    cout<<"|   see. The …
c++ prog 0 Light Poster

this code is a game that uses socket to be able to connect to each other so that there would be a 2player game.. but there something wrong here...here's the code..i'm using linux as my operating system ..this is the client side..

#include <stdio.h>
#include <iostream>
//#include <conio.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>

using namespace std;

void error(char *msg)
{
  perror(msg);
  exit(0);
}


int main(int argc, char *argv[])
{
	int  sockfd,portno, n, n1; 
	struct sockaddr_in serv_addr;
	struct hostent *server;
	
	
	char buffer[256];
	if (argc < 3) {
	   fprintf(stderr,"usage %s hostname port\n", argv[0]);
	   exit(0);
	}
	portno = atoi(argv[2]);
	sockfd = socket(AF_INET, SOCK_STREAM, 0);
	if (sockfd < 0)
	   error("ERROR opening socket");
	server = gethostbyname(argv[1]);
	if (server == NULL) {
	   fprintf(stderr,"ERROR, no such host\n");
	   exit(0);
	}
	bzero((char *) &serv_addr, sizeof(serv_addr));
	serv_addr.sin_family = AF_INET;
	bcopy((char *)server->h_addr,
	   (char *)&serv_addr.sin_addr.s_addr,
	   server->h_length);
	serv_addr.sin_port = htons(portno);
	//if (connect(sockfd,&serv_addr,sizeof(serv_addr)) < 0)
	//   error("ERROR connecting");
	//if (connect(sockfd, &serv_addr,sizeof(serv_addr)) < 0) 
        //error("ERROR connecting");	
	printf("Welcome to Battle of Jack 'en Poy\n");
	printf("Please enter your name: ");
	bzero(buffer,256);
	fgets(buffer,255,stdin);
	n = write(sockfd,buffer,strlen(buffer));
	bzero(buffer,256);
	n = write(sockfd," ! ",3);
	
	if (n < 0)
	    error("ERROR writing to socket");
	bzero(buffer,256);
	n = read(sockfd,buffer,255);
	if (n < 0)
	    error("ERROR reading from socket");
		printf("%s\n",buffer);
	return 0;

       
}

this is the server side..

#include <cstdlib>
#include <iostream>
#include <iomanip>
#include <string>
#include <time.h>
#include <windows.h>
#include <conio.h>

using namespace std;

#define splayer 1
#define cplayer 0


char buffer_name[256];
int newsockfd;
int n;

void error(char *msg)
{
  perror(msg);
  exit(1);
}

void game();

string player1="^^^"; …
c++ prog 0 Light Poster

but we haven't discussed it yet those..I don't have any idea.. and I think it's already an advanced programming... so my professor will understand my situation. Anyway, I revised the game and it still looks fine even without the timer...

c++ prog 0 Light Poster

so it can be done using multithreading...and i don't even have any idea how to do one! lol...maybe i'll just scrap the timer idea on the game..but tnx anyways for your response

c++ prog 0 Light Poster

Is it posibble to have a count-down timer while I'm doing something else in the console? it's a simple game wherein a specified time is allowed for the player..if possible, how? I created a timer but it waits until it finishes before proceding to the game..tnx in advance

c++ prog 0 Light Poster

hi, im creating a simple game here...its a shooting game...so how can I make my program read the keyboard to control the player's movement around?tnx in advance

c++ prog 0 Light Poster

can anyone recommend me a website with a sample of socket which can help me create a 2-player game in c++, or much better, a game using socket?tnx

c++ prog 0 Light Poster

websites is not really my specialty...so how can I connect modules? and also how can a user update, lets say his bulletin, by just editing it just like in multiply...any suggestions or online tutorials will be appreciated ..tnx

c++ prog 0 Light Poster

Can anyone suggest a good website that can teach me Oracle? thanks in advance..

c++ prog 0 Light Poster

our group made a decision to do a dynamic website, and the best tool for this is PHP! But this is too risky...why? because none of us has any background on it!!! can anyone recommend a site that can teach me how to use PHP...any help would be appreciated..tnx

c++ prog 0 Light Poster

guys, i have a project to do this school year, and that is a dynamic website..the problem is that i don't have a good background with dhtml so can anyone recommend me a website that can teach me how???tnx

c++ prog 0 Light Poster

simply create an option for the user to choose...lets say switch case is the best way

c++ prog 0 Light Poster

help plz...I have to create a program that multiplies matrices...those elements in the array must come from a file or reads a file...I have constructed these codes but this program lets the user type their number, not read from a file..I have these code so far...

#include <cstdlib>
#include <iostream>
#include <fstream>
using namespace std;


int main ()
 {
   int a[3][5];
   int b[5][4];
   int answer[3][4];

   int i,j,k;   
   int temp; 
   fstream InFile;
   InFile.open("readfile.txt", ios::in);

  /*type in values for first array */

   cout << "Enter values for array A." << endl;
   for (i = 1; i <= 2; i++)
     { cout << "Row number " << i << endl;
       for (j = 1; j <= 4; j++)
          { cout << "  Element number " << j << " : ";
            cin >> a[i][j];
          }
     }

  /*type in values for second array */

   cout << "Enter values for array B." << endl;
   for (i = 1; i <= 4; i++)
     { cout << "Row number " << i << endl;
       for (j = 1; j <= 3; j++)
          { cout << "  Element number " << j << " : ";
            cin >> b[i][j];
          }
     }

  /*calculate answers in answer array */

   for (i = 1; i <= 2; i++)
      for (j = 1; j <= 3; j++)
         {
           temp = 0;   /* Build up answer here */
           for (k = 1; k <= 4; k++)
              temp += a[i][k] * b[k][j];
           answer[i][j] = temp;
         }

   /*display the answers */

   for (i = …
c++ prog 0 Light Poster

can u at least put some spaces in between your sentences..

c++ prog 0 Light Poster

Hey!!! Show some effort! even if your a newbie, you should exert some effort!

c++ prog 0 Light Poster

uhhm windows mediaplayer

c++ prog 0 Light Poster

i've been developing a game for quite some time now...it will be finished soon...my only concern now is how to make my game more interesting to the gamer's eyes...so i included a video to be able to give a brief background of how the story unfolds...but the problem is that i don't know how the .net would determine a video, an MPEG, has ended so that it may proceed to another form...can anyone help me plz?

c++ prog 0 Light Poster

uhhm an mpeg video....

c++ prog 0 Light Poster

i've been developing a game for quite some time now...it will be finished soon...my only concern now is how to make my game more interesting to the gamer's eyes...so i included a video to be able to give a brief background of how the story unfolds...but the problem is that i don't know how the .net would determone a video has ended so that it may proceed to another form...can anyone help me plz?

c++ prog 0 Light Poster

of course there is a way..

c++ prog 0 Light Poster

can anyone suggest any website that will help me a lot on creating a simple chatbox? tnx

c++ prog 0 Light Poster

can anyone plz tell me how to add a movie in the form?particularly mpg? any examples would really help me...tnx

c++ prog 0 Light Poster

can anyone plz tell me how to add a movie in the form? any examples would really help me...tnx!

c++ prog 0 Light Poster

can anyone teach me how to correct my code....when I debug this the 12th line or the sndPlaySound("shot.wav", SND_ASYNC) line shows an error "A call to PInvoke function 'StartForm!StartForm.StartForm::sndPlaySound' has unbalanced the stack. This is likely because the managed PInvoke ".Please help me with this one this is a requirement for us to be able to pass the subject...tnx guyz

Public Class StartForm

Declare Function sndPlaySound Lib "winmm.dll " Alias "sndPlaySoundA" (ByVal Name As String, ByVal Flags As Long) As Long
Private Const SND_ASYNC As Int32 = &H1
Private BlnSounds As Boolean = True

Public Sub PictureBox1 _Click(blah blah blah)
On Error GoTo fix
If Start = True Then
            If MenuItem4.Checked = True Then
                sndPlaySound("shot.wav", SND_ASYNC)
            Else
            End If
            Bullets = Bullets - 1
            Points = Points + 1
            Label2.Text = "Bullets : " & Bullets
            Label3.Text = "Score : " & Points
            If Bullets = 0 Then
                Start = False
                MenuItem3.Enabled = False
                MsgBox("Bullets over!" & Chr(13) & "Game over!", vbCritical, "Out of bullets!")
            End If
            Me.PictureBox3.BackColor = Color.Red
            Me.PictureBox3.Cursor = Cursors.SizeAll
        Else
            If Points = 20 Then
                Start = False
                MenuItem3.Enabled = False
                MsgBox("You exterminated all Gays!!!You won the game!!!")
            End If

        End If
End Sub
End Class
c++ prog 0 Light Poster

using namespace std;
is required for u 2 be able to use cin only

c++ prog 0 Light Poster

I'm creating a game here using a vb.net.....to make my project more interesting, i'll add a flash animation before the game begins to serve as the story of the game....but the problem is i don't know how to add it into a form....i didn't found anything in the toolbox that can help me...

c++ prog 0 Light Poster

This Is the code for the image.....this is only the left to right basis in random

Private Sub YanigSaBanig_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseMove
        Me.Button1.Location = e.Location
        On Error GoTo fix

        If Start = True Then
            If e.X <= (YanigSaBanig.ActiveForm.Width / 2) Then
                PictureBox2.Visible = False
                PictureBox1.Visible = True
                PictureBox3.BackColor = Color.White
            Else
                PictureBox1.Visible = False
                PictureBox2.Visible = True
            End If
        End If

fix:    Exit Sub
    End Sub
c++ prog 0 Light Poster

I've been working on a Linked List assignment. I completed it but I still have a problem on deleting an element that has a predecessor or after an element and inserting an element after an element...can anyone give me an idea?
This is what I have so far

#include <iostream>
    using namespace std;

    struct Node{
    int x, y;
    Node *next;
    };
    Node *start_ptr = NULL;

    void traversal()
    {
    Node *temp;
    temp = new Node;
    temp = start_ptr;
    while (temp != NULL)
    {
    temp = temp -> next;
    }
    }
    void delete_start__node()
    {
    Node *temp;
    temp = start_ptr;
    start_ptr = start_ptr -> next;
    delete temp;
    }
    void insert_at_Beginning()
    {
    Node *newptr;
    newptr = new Node;
    newptr -> next = start_ptr;
    start_ptr = newptr;
    }
c++ prog 0 Light Poster

does anyone know the game about saddam being shot in miniclip in flash? I have been working on a game but I dont know How to make saddam apper on the screen...example...on a desk he will rise up then will go down...then he will rise again beside a computer then will go down again until he disappers...I have randomized the image but it's on the left 2 right basis only not left, right, up and down basis...can anyone suggest how I will solve my problem plz????

c++ prog 0 Light Poster

does anyone know the game about saddam being shot in miniclip in flash? I have been working on a game but I dont know How to make saddam apper on the screen...example...on a desk he will rise up then will go down...then he will rise again beside a computer then will go down again until he disappers...I have randomized the image but it's on the left 2 right basis only not left, right, up and down basis...can anyone suggest how I will solve my problem plz????

c++ prog 0 Light Poster

can u pls teach me how to use this method

int x;
x=temp - '0';

i think i created the wrong program..it should read each digit not convert it into integer...

c++ prog 0 Light Poster

this program should add 2 integers in the range of 20 digits, but only 10 digits are allowed, else the sum would be incorrect. can anyone plz show me what's wrong with my codes? Here's what i got so far....

#include <cstdlib>
#include <iostream>

using namespace std;

int main(int argc, char *argv[])
{
    char option=' ' ;
    while ( (option != 'Q') and (option != 'q') )
    {
          cout << "Select : (C)ontinue (Q)uit:" ;
          cin >> option ;
          switch (option)
          { 
                 case 'C' : case 'c': //user chose to continue
                      {  
                               cout << "Enter number in the range of 1-20 digits: " << endl;
                               char c[20] ;
                               cin >> c ;
                               int x = atoi (c) ; //convert into int
                               int num[20] ;
                               for (int i = 0; i < 20; i++)
                               {       
                                       char temp = c[i] ;
                                       num[i] = atoi(&temp) ;
                               }
                               cout << "Enter 2nd number in the range of 1-20 digits: " << endl ;
                               char d[20] ;
                               cin >> d ; 
                               int y = atoi(d) ;//convert into int
                               int num2[20] ;
                               for(int e = 0; e < 20; e++)
                               {
                                      char temp2 = d[e] ;
                                      num2[e] = atoi(&temp2) ;
                               }
                               int total = atoi(c) + atoi(d) ;
                               cout << "The total is " ;
                               cout << total << endl;
                      }
          }
     }

    system("PAUSE");
    return EXIT_SUCCESS;
}
c++ prog 0 Light Poster

i'm new to c++....i'm making a project here but i have a problem with this: reading values as type char and converting it to type int...such that 54 can be read as '5' and '4' but after that it will be read into type int...can anyone please tell me how?

c++ prog 0 Light Poster

i'm new to c++....i'm making a project here but i have a problem with this: reading values as type char and converting it to type int...such that 54 can be read as '5' and '4' but after that it will be read into type int...can anyone please tell me how?