You are viewing our Forum Archives. To view or take place in current topics click here.
3 Prog languages?
Posted:

3 Prog languages?Posted:

NicknKickn
  • Winter 2020
Status: Offline
Joined: Dec 22, 200914Year Member
Posts: 916
Reputation Power: 282
Status: Offline
Joined: Dec 22, 200914Year Member
Posts: 916
Reputation Power: 282
Okay, so I've got a huge problem. Tomorrow, for class, I have to turn in three separate programs in three separate coding languages, I got one program finished in Java, perfectly fine, that isn't the issue. The issue is, I don't know any other languages, and learning an entire language, let alone 2 in a night, is next to impossible for anyone, so I was wondering what the community would suggest? What languages are quick and simple? C++, Python, POV-Ray, MSBasics, what do you all suggest?

If anyone wishes to offer help to me, this is what I need done:
1. Declare an array of integers
2. Initialize 10 random integers
3. Print the array.
4. Sort the array.
5. Print the sorted array.

I know it sounds extremely simple, but realize I'm new to coding, especially to languages outside Java.
For those wondering about my Java code, here it is:

/**
* File: JavaArray.java
* Author: Nicholas M
* Special Topics: 1st Hour
* Last Modified: January 14, 2013
* Description: This program declares an array of 10 integers, prints them
* and then uses the Arrays.sort method (imported) to sort the arrays in
* ascending order. The sorted array is given a forloop which prints out
* the arrays in the ascended order.
*/

import java.util.Arrays;

public class JavaArray
{
public static void main(String[] args)
{
int[] JavaArray; // declares an array of integers.

JavaArray = new int[10]; // gives array memory for 10 integers.

JavaArray[0] = 47; // instantiate first array value.
JavaArray[1] = 223; // instantiate second array value.
JavaArray[2] = 39; // etc.
JavaArray[3] = 54;
JavaArray[4] = 856;
JavaArray[5] = 254;
JavaArray[6] = 224;
JavaArray[7] = 40;
JavaArray[8] = 46;
JavaArray[9] = 10; // instantiate final array value.

System.out.println("The arrays (not in order):");

for (int j = 0; j < JavaArray.length; j++)
{
System.out.println(JavaArray[j]);
}

System.out.println("Sorting of the arrays from least to greatest:");

Arrays.sort(JavaArray);

for (int a = 0; a < JavaArray.length; a++) // I made a forloop, as I am to lazy to type "System.out
{ // .println 50 more times.
System.out.println(JavaArray[a]); // makes a loop to print Arrays to Java Application.
}
}
} // End program done.
#2. Posted:
NicknKickn
  • Christmas!
Status: Offline
Joined: Dec 22, 200914Year Member
Posts: 916
Reputation Power: 282
Status: Offline
Joined: Dec 22, 200914Year Member
Posts: 916
Reputation Power: 282
Anyone who knows how to do this/wants to help/offer advice?
#3. Posted:
TTGXMODsX
  • TTG Natural
Status: Offline
Joined: Feb 06, 201014Year Member
Posts: 996
Reputation Power: 64
Status: Offline
Joined: Feb 06, 201014Year Member
Posts: 996
Reputation Power: 64
NicknKickn wrote Anyone who knows how to do this/wants to help/offer advice?


You need to do something like this for c#:


        static void Main(string[] args)
        {
            int[] randomNum = new int[1000];
            Random RandomNumber = new Random();


            for ( int i = 0; i<1000; i++)
            {
                randomNum[i] = RandomNumber.Next(1, 1000);
            }


            foreach (int j in randomNum)
            {
                Console.WriteLine("First Number:{0}",  j);
            }
           

            Console.Read();


This is for C:

#include <stdlib.h>
#include <stdio.h>
#include <time.h>

        int main(void) {
        int i;

        srand(time(NULL));

        for (i = 1; i <= 10; i++) {
        printf("%10d", 1 + (rand() % 6));
      
        if (i % 5 == 0) {
        printf("\n");
      }
   }

       return 0;
}


And it would help to know what the actual question was
#4. Posted:
NicknKickn
  • TTG Natural
Status: Offline
Joined: Dec 22, 200914Year Member
Posts: 916
Reputation Power: 282
Status: Offline
Joined: Dec 22, 200914Year Member
Posts: 916
Reputation Power: 282
I actually finished a new program in C++, I learnt enough in the past 4 hours by watching videos to do so. There is one thing I still need though, a program in another language that did the 5 things I posted about earlier, any good with Python?
Jump to:
You are viewing our Forum Archives. To view or take place in current topics click here.