[VIEWED 84385
TIMES]
|
SAVE! for ease of future access.
|
|
|
|
Ayus
Please log in to subscribe to Ayus's postings.
Posted on 02-14-11 10:39
PM
Reply
[Subscribe]
|
Login in to Rate this Post:
1
?
Liked by
|
|
Shoot out your problems...
Lets share and expand the knowledge.....!!!!
We are open to share on(any IT related stuffs) :
- Javascript/JQuery/Ajax
- Java,JSP,Servlets and Frameworks
- WebServices
- Unix, Linux, Webserver Administration
+ many more !!!!
|
|
|
|
shivabuti
Please log in to subscribe to shivabuti's postings.
Posted on 04-19-11 3:50
PM [Snapshot: 3908]
Reply
[Subscribe]
|
Login in to Rate this Post:
0
?
|
|
I mean I tried searching "sorting pseudo-code" but could not get the right input. Thanks again.
|
|
|
prankster
Please log in to subscribe to prankster's postings.
Posted on 04-19-11 4:19
PM [Snapshot: 3912]
Reply
[Subscribe]
|
Login in to Rate this Post:
1
?
Liked by
|
|
|
|
|
nepali8
Please log in to subscribe to nepali8's postings.
Posted on 04-21-11 1:45
AM [Snapshot: 3955]
Reply
[Subscribe]
|
Login in to Rate this Post:
0
?
|
|
Namaste!!! to all c++ programmer
The file named data.txt. contains a different integers value.This file contains a long list of random numbers. write a program that opens the file, reads all the numbers from the file, and calculates the following.
A) The number of numbers in the file
B) The sum of all the numbers in the file( a running total)
c) The average of all the numbers in the file.
The program should display the number of numbers found in the file, the sum of the numbers, and the average of the numbers
My ans:
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
ifstream inputFile;
int number;
int i = 1;
int sum = 0;
double average = 0.0;
inputFile.open("data.txt");
if (!inputFile)
cout << "Can not open File.\n";
else
{
while(i < 201) // i just count it all the value from the file.
{
if(inputFile >> number)
cout << number << endl;
else
break;
sum +=number;
average = sum/i;
}
inputFile.close();
}
cout <<"Sum is" <<sum <<endl;
cout <<"average is" << average << endl;
return 0;
}
I would like to know if there some other way to do it., instead of counting integer value from data.txt file.
|
|
|
Ayus
Please log in to subscribe to Ayus's postings.
Posted on 04-21-11 9:04
AM [Snapshot: 3973]
Reply
[Subscribe]
|
Login in to Rate this Post:
0
?
|
|
i m not into C++ but just wondering why u r using 201 in while loop ?
Why use constant value to read from file? what if your number changes in your file?
put a condition until u reach end of a file. use eof() function.
|
|
|
bange
Please log in to subscribe to bange's postings.
Posted on 04-21-11 9:33
AM [Snapshot: 3977]
Reply
[Subscribe]
|
Login in to Rate this Post:
0
?
|
|
Namaste nepali8, good to see you are doing on your own (hope this is not copied ). As Ayus said, and you've realized too,
its not good to hard code the values. Try something like below on the above section.
int count = 0;
while(! inputFile.eof()) // i just count it all the value from the file.
{
if(inputFile >> number)
{
cout << number << endl;
count ++;
}
else
break;
sum +=number;
average = sum/i;
}
inputFile.close();
}
cout<<"Count is "<<count<<endl;
cout <<"Sum is" <<sum <<endl;
cout <<"average is" << average << endl;
|
|
|
nepali8
Please log in to subscribe to nepali8's postings.
Posted on 04-21-11 12:31
PM [Snapshot: 4002]
Reply
[Subscribe]
|
Login in to Rate this Post:
0
?
|
|
Namaste!!!!!!!!!!!!
Thanks Guys
|
|
|
Java_help
Please log in to subscribe to Java_help's postings.
Posted on 04-22-11 2:58
PM [Snapshot: 4038]
Reply
[Subscribe]
|
Login in to Rate this Post:
0
?
|
|
Please help me with this. Thank you in advance :)
This homework is geared towards fine tuning your programming and understanding of GUI/graphics/threading skills. You will be adopting a working (but not correct) game of ping pong in Java, porting it from Applet to Java Swing. You will also be practicing your thread programming skills.
I have made the basic Ping Pong source code available. Please download the code, and make sure you can get it running. To help you along, I’m outlining step by step guidelines for you to follow.
1) Basic port
- First start by getting the applet version to run.
- You need to use threads in this project.
- Now look over the code and understand how the pieces work together.
- Create a new Java project. You will be porting each of the classes from the example code to swing, so its better to code in empty class and fill in the details….feel free to rename or rethink the pieces of the program, make sure each of the next steps runs before continuing to the next step, MAKE SURE TO ADD COMMENTS TO YOUR CODE.
- Don’t do anything except get a blank window to open up (and close/exit correctly).
- Port the field class so that you can display a colored field (switch the background color to whatever you like.
- Port the ball class, so that you can get a bouncing ball on the screen. Don’t forget to play around with the ball color.
- Get the ball to bounce around the screen (for this step you can leave it as it is so that it bounces off the back wall back into the game
- Port the paddle so that it shows up in the game.
2) More complicated coding
- Add a score counter; so you can show the current score
- Add a miss counter; to show how many times the paddle missed the ball
- Add a hit counter; so that every time the ball is hit, the number is incremented….i.e. every time the ball and paddle meet, the number goes up by one.
- Convert the ball class, it so that it works for the current window’s size….and not as it is done…i.e. if I resize the window, it will still work.
- Make sure you are not hard coding any of your code to a specific window size
- Change it so that if the ball misses the paddle (to the right of the paddle) it disappears and the miss counter is incremented.
- Every 10 times you hit the ball you should get 1 point (on the score counter).
3) Test to see if you can play a regular game of ping pong.
Submit your .java source code files as your assignment submission.
|
|
|
Java_help
Please log in to subscribe to Java_help's postings.
Posted on 04-22-11 3:20
PM [Snapshot: 4049]
Reply
[Subscribe]
|
Login in to Rate this Post:
0
?
|
|
package pingpong;
import java.awt.*;
import java.applet.*;
/*
*
* ball
*
*/
class ball
{
final int LEFT=0, RIGHT = 1, UP = 2, DOWN = 3;
final int LEFT_WALL = 10, RIGHT_WALL = 300, TOP_WALL = 10, BOTTOM_WALL = 220;
int x_pos, y_pos, size;
int dir_x, dir_y;
int xinc = 10, yinc = 8;
Graphics g;
paddle p;
Applet owner;
void setApplet (Applet a)
{
owner = a;
}
void setPaddle(paddle pp)
{
p = pp;
}
void setGraphics(Graphics gr)
{
g = gr;
}
void move()
{
switch (dir_x)
{
case LEFT:
{
x_pos -= xinc;
if (x_pos < LEFT_WALL)
{
x_pos = LEFT_WALL;
dir_x = RIGHT;
}
}
break;
case RIGHT:
{
//paddle-ball intersection goes here
x_pos += xinc;
if (x_pos > RIGHT_WALL)
{
if ((y_pos > p.getBottom()) || (y_pos < p.getTop()))
{
//die
owner.showStatus("You missed the ball!");
x_pos = RIGHT_WALL;
dir_x = LEFT;
}
else
{
x_pos = RIGHT_WALL;
dir_x = LEFT;
owner.showStatus("You hit it! Good job!");
|
|
|
Java_help
Please log in to subscribe to Java_help's postings.
Posted on 04-22-11 3:22
PM [Snapshot: 4051]
Reply
[Subscribe]
|
Login in to Rate this Post:
0
?
|
|
package pingpong;
import java.awt.*;
/*
*
* field
*
*/
class field
{
int x_pos, y_pos, width, height;
Graphics g;
field (int x, int y, int w, int h)
{
x_pos = x;
y_pos = y;
width = w;
height = h;
}
void setGraphics (Graphics gr)
{
g = gr;
}
void draw ()
{
int x, y;
//g.setColor(Color.green);
//for (x = 0; x < width; x += 10)
// g.drawLine(x, 0, x, height);
//g.setColor(Color.red);
//for (y = 0; y < height; y += 10)
// g.drawLine(0, y, width, y);
//g.setColor(Color.black);
g.fillRect( 0, 0, width, 10);
g.fillRect(0, 0, 10, height);
g.fillRect(0, height - 10, width, height);
}
void erase ()
{
g.setColor(Color.white);
draw();
g.setColor(Color.black);
}
void move (int x, int y)
{
x_pos = x;
y_pos = y;
}
}
|
|
|
Java_help
Please log in to subscribe to Java_help's postings.
Posted on 04-22-11 3:23
PM [Snapshot: 4054]
Reply
[Subscribe]
|
Login in to Rate this Post:
0
?
|
|
package pingpong;
import java.awt.*;
/*
*
* paddle
*
*/
class paddle
{
final int PADDLE_HEIGHT = 60;
int x_pos, y_pos, new_y_pos;
Graphics g;
int getTop()
{
return y_pos;
}
int getBottom()
{
return y_pos + PADDLE_HEIGHT;
}
paddle(int x, int y)
{
x_pos = x;
y_pos = y;
new_y_pos = y;
}
void setGraphics (Graphics gr)
{
g = gr;
}
void draw ()
{
g.setColor(Color.white);
g.fillRect( x_pos, y_pos, 10, PADDLE_HEIGHT);
g.setColor(Color.black);
y_pos = new_y_pos;
g.fillRect( x_pos, y_pos, 10, PADDLE_HEIGHT);
}
void move (int y)
{
new_y_pos = y;
}
}
|
|
|
Java_help
Please log in to subscribe to Java_help's postings.
Posted on 04-22-11 3:23
PM [Snapshot: 4057]
Reply
[Subscribe]
|
Login in to Rate this Post:
0
?
|
|
package pingpong;
import java.applet.*;
import java.awt.*;
public class paddlegame extends Applet implements Runnable
{
Image imgBuffer;
Graphics gBuffer;
paddle padObj;
field f;
ball ballObj;
Thread runner = null;
public paddlegame()
{
}
public void update(Graphics g)
{
paint(g);
}
public void start()
{
if(runner == null)
{
runner = new Thread(this);
runner.start();
}
}
public void run()
{
while (runner != null)
{
//move ball and paddle here
padObj.draw();
ballObj.draw();
//f.draw();
try {Thread.sleep(30);} catch (InterruptedException e){}
repaint();
}
runner = null;
}
public String getAppletInfo()
{
return "Name: paddlegame\r\n" +
"Author: Unknown\r\n" +
"Created with Microsoft Visual J++ Version 1.0";
}
public void init()
{
resize(320, 240);
imgBuffer = createImage (getSize().width, getSize().height);
gBuffer = imgBuffer.getGraphics();
gBuffer.setColor(Color.white);
gBuffer.fillRect(0,0,getSize().width, getSize().height);
gBuffer.setColor(Color.black);
padObj = new paddle(310, 100);
ballObj = new ball(30, 30, 10);
f = new field(0, 0, 320, 240);
padObj.setGraphics(gBuffer);
ballObj.setGraphics(gBuffer);
f.setGraphics(gBuffer);
ballObj.setPaddle(padObj);
ballObj.setApplet(this);
f.draw();
padObj.draw();
ballObj.draw();
}
public void destroy()
{
}
public void paint(Graphics g)
{
g.drawImage(imgBuffer, 0, 0, this);
}
public boolean mouseMove (Event e, int x, int y)
{
padObj.move(y);
return false;
}
}
|
|
|
Gmoney
Please log in to subscribe to Gmoney's postings.
Posted on 04-22-11 3:37
PM [Snapshot: 4062]
Reply
[Subscribe]
|
Login in to Rate this Post:
0
?
|
|
Any help with the below questions is greatly appreciated.
Switches are often prices by number of interfaces (also called ports in LAN jargon). Roughly what is the current per-interface price range for a switch consisting of only 100 Mps interfaces?
List five products on the market today that provide a Bluetooth or 802.15 interface.
Suppose that an intruder could insert DNS messages into and remove DNS messages from DNS servers. Give three scenarios showing the problems that such an intruder could cause.
Besides a power plant or an airplane cockpit, what is an analogy of a complex distributed system needs to be controlled?
|
|
|
bange
Please log in to subscribe to bange's postings.
Posted on 04-22-11 3:56
PM [Snapshot: 4068]
Reply
[Subscribe]
|
Login in to Rate this Post:
0
?
|
|
@gmoney
Switchesare often prices by number ofinterfaces(also called ports inLANjargon). Roughly what is the current per-interface price range for a switch consisting of only 100 Mps interfaces?
http://www.google.com/#q=a+switch+consisting+of+only+100+Mps+interfaces&bav=on.2,or.r_gc.r_pw.&fp=435e185a007639bf&hl=en&tbm=shop
List five products onthe markettoday that provide a Bluetooth or 802.15 interface.
http://www.google.com/#q=products+on+the+market+today+that+provide+a+Bluetooth+and+802.15+interface.&bav=on.2,or.r_gc.r_pw.&fp=435e185a007639bf&hl=en&spell=1&tbm=shop
Suppose that an intruder could insert DNS messages into and remove DNS messages from DNS servers. Give three scenarios showing the problems that such an intruder could cause.
http://lmgtfy.com/?q=problem+with+dns+intruder&l=1
Besides a power plant or an airplane cockpit, what is an analogy of a complex distributed system needs to be controlled?
http://luhman.org/japanese-reports/sell-to-japan/030-japans-complex-distribution-system
|
|
|
nepali8
Please log in to subscribe to nepali8's postings.
Posted on 04-23-11 6:02
PM [Snapshot: 4127]
Reply
[Subscribe]
|
Login in to Rate this Post:
0
?
|
|
Namaste! I need some information. If you could help me out. I have a hp lap top which was intially 2003 vista installed on it. Later on upgraded to window 2007 an aslo currently running 2007. Its kind of slow, and also i would like to mention that there is message showing "this copy of window is not geniuene". i need to reformat this computer to factory setting. How can i do that?
|
|
|
Ayus
Please log in to subscribe to Ayus's postings.
Posted on 04-24-11 8:14
PM [Snapshot: 4168]
Reply
[Subscribe]
|
Login in to Rate this Post:
0
?
|
|
@nepali8
download this file: removewat22.zip
|
|
|
nepali8
Please log in to subscribe to nepali8's postings.
Posted on 04-24-11 9:23
PM [Snapshot: 4186]
Reply
[Subscribe]
|
Login in to Rate this Post:
0
?
|
|
hey guys!!!
need help in c#
i need some information on radio button and picture box in windows form programming. what i am trying to do is, whenever user checked on a radion button, it should display message and the image should open on pciture box. i have already done displaying message whenever user checked on radio button. but im stuck on displaying image on picture box.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace chapter9
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void btnskiing_CheckedChanged(object sender, EventArgs e)
{
if (btnskiing.Checked == true)
MessageBox.Show("Get Ready");
}
private void btnRunning_CheckedChanged(object sender, EventArgs e)
{
if (btnRunning.Checked == true)
MessageBox.Show("Get Your shoes ready");
}
private void btnSwimming_CheckedChanged(object sender, EventArgs e)
{
if (btnSwimming.Checked == true)
MessageBox.Show("Get Your swim suit");
}
private void btnBasketball_CheckedChanged(object sender, EventArgs e)
{
if (btnBasketball.Checked == true)
MessageBox.Show("Are you ready hit the score");
}
private void btnSoccer_CheckedChanged(object sender, EventArgs e)
{
if (btnSoccer.Checked == true)
MessageBox.Show("Goal, Goal, Goal");
}
}
}
thanks for help!!
|
|
|
amricane
Please log in to subscribe to amricane's postings.
Posted on 04-25-11 1:22
PM [Snapshot: 4256]
Reply
[Subscribe]
|
Login in to Rate this Post:
0
?
|
|
o
Last edited: 25-Apr-11 02:35 PM
|
|
|
nepali8
Please log in to subscribe to nepali8's postings.
Posted on 04-25-11 10:33
PM [Snapshot: 4302]
Reply
[Subscribe]
|
Login in to Rate this Post:
0
?
|
|
Namaste!!!!!!!!
need help in c#
i need some information on radio button and picture box in windows form programming. what i am trying to do is, whenever user checked on a radion button, it should display message and the image should open on pciture box. i have already done displaying message whenever user checked on radio button. but im stuck on displaying image on picture box.
Thanks
|
|
|
Ayus
Please log in to subscribe to Ayus's postings.
Posted on 04-26-11 9:26
AM [Snapshot: 4331]
Reply
[Subscribe]
|
Login in to Rate this Post:
0
?
|
|
try this:
// open file dialog
OpenFileDialog open = new OpenFileDialog();
// image filters
open.Filter = "Image Files(*.jpg; *.jpeg; *.gif; *.bmp)|*.jpg; *.jpeg; *.gif; *.bmp";
if (open.ShowDialog() == DialogResult.OK)
{
// display image in picture box
pictureBox1.Image = new Bitmap(open.FileName);
// image file path
textBox1.Text = open.FileName;
}
|
|
|
nepali8
Please log in to subscribe to nepali8's postings.
Posted on 05-02-11 2:19
PM [Snapshot: 4428]
Reply
[Subscribe]
|
Login in to Rate this Post:
0
?
|
|
Nameste!!!!
Need some favour from you guys. I am trying to set up home sever. I have a dell inspiron 530, desktop compter, currently running windows home server 2003 which i have recently installed it. I tried to connect to internet through LAN but im not able. I think im missing a driver . So please let me know if any of you guys know.
thanks.
|
|