Monday, May 24, 2010

Programmers please help!! T_T?

I need a complete source code for java and c++... here's the problem:





Create an array and put the first ten even numbers in the array as evenlist...





Display evenlist in reverse order.





***i'm still in my first yr. college and i'm not really that knowledgeable about programming...it really bothered me a lot.hope for your unconditional help in java and C++ complete source code....thanx n advance!

Programmers please help!! T_T?
Java:





int[] evenlist = new int[10];





for (int x = 0; x %26lt; 10; x++) {


evenlist[x] = (x + 1) * 2;


}





for (int x = 9; x %26gt;= 0; x--) {


System.out.println(evenlist[x]);


}
Reply:***i'm still in my first yr. college and i'm not really that knowledgeable about programming***





This is what you say in your question. My statement to you is...If you keep having people write your code for you, you will never learn how to write it yourself and therefore you will never learn anything. What would you do if when you graduated you obtained a position as a coder at XYZ company, they throw a project on your desk and then you cant write the code to make it function?? You gonna post that here too?





Think about it! We don't learn and educate ourselves by copying from others work.





I am a web applications and design student myself. I am not trying to come down on you, but what I say is true.





Read your text, try and write the code yourself.


If at first you don't succeed try again.





peace,


mavin





P.S. I noticed this is not the only question you have up regarding code, What were you doing instead of studying??


No offense but it seems you need to get your priorities straight :/
Reply:/*File: Array01.cpp


This C++ program illustrates the use of a simple


one-dimensional array in C++.





The program asks the user to enter five integer


values in succession. It stores the values in


reverse order in an array. Then it displays the


contents of the array in forward order.





Then it computes and displays the average of the


values stored in the array, the minimum value


stored in the array, and the maximum value


stored in the array.





The program displays the following output on the


screen for a typical set of input data:





Enter an integer value: -100


Enter an integer value: -50


Enter an integer value: 0


Enter an integer value: 49


Enter an integer value: 99


Array contents:


99 49 0 -50 -100


Average: -0.4


Minimum: -100


Maximum: 99





**************************************...





#include %26lt;iostream%26gt;


using namespace std;





class Array01{


public:


static void classMain(){


Array01* ptrToObject = new Array01();


ptrToObject -%26gt; doSomething();


}//End classMain function


//--------------------------------------...





//An instance function of the Array01 class


void doSomething(){


const int size = 5;


long values[size];


//Populate the array in reverse order.


getData(values,size);


//Display contents of the array in forward


// order.


cout %26lt;%26lt; "Array contents:" %26lt;%26lt; endl;


displayData(values,size);


//Compute and display average, minimum, and


// maximum values.


cout %26lt;%26lt; "Average: " %26lt;%26lt; getAvg(values,size)


%26lt;%26lt; endl;


cout %26lt;%26lt; "Minimum: " %26lt;%26lt; getMin(values,size)


%26lt;%26lt; endl;


cout %26lt;%26lt; "Maximum: " %26lt;%26lt; getMax(values,size)


%26lt;%26lt; endl;


}//end doSomething function


//--------------------------------------...





void getData(long array[],int size){


int count = size - 1;


while(count %26gt;= 0){


cout %26lt;%26lt; "Enter an integer value: ";


cin %26gt;%26gt; array[count];


count = count - 1;


}//end while loop


}//end getData


//--------------------------------------...





void displayData(long array[],int size){


int count = 0;


while(count %26lt; size){


cout %26lt;%26lt; array[count] %26lt;%26lt; " ";


count = count + 1;


}//end while loop


cout %26lt;%26lt; endl;


}//end displayData


//--------------------------------------...





double getAvg(long array[],int size){


int count = 0;


double sum = 0;


while(count %26lt; size){


sum = sum + array[count];


count = count + 1;


}//end while loop


return sum/size;


}//end getAvg


//--------------------------------------...





long getMin(long array[],int size){


long min = 2147483647;


int count = 0;


while(count %26lt; size){


if(array[count] %26lt; min){


min = array[count];


}//end if


count = count + 1;


}//end while loop


return min;


}//end getMin


//--------------------------------------...





long getMax(long array[],int size){


long max = -2147483648;


int count = 0;


while(count %26lt; size){


if(array[count] %26gt; max){


max = array[count];


}//end if


count = count + 1;


}//end while loop


return max;


}//end getMax


//--------------------------------------...





};//End Array01 class


//------------------------------------...





int main(){


Array01::classMain();


return 0;


}//end main





I hope it work for u
Reply:In C++





#include%26lt;iostream.h%26gt;


#include%26lt;conio.h%26gt;


using namespace std;


int main(){





int evenarray[10];


for(i=0;i%26lt;10;i++)


{


evenarray[i]=2*i;


}





for(i=0;i%26lt;10;i++)


{


cout%26lt;%26lt; evenarray[10-i]%26lt;%26lt;endl;


}


System("pause");


return 0;


}
Reply:there is a site that has a tutorial for c++ and java script. search in google.. be productive and u must learn it with your own beacause starting as a programmer is a big responsibility in the future.


No comments:

Post a Comment