Jump to content

I need help with this.


onox37

Recommended Posts

I need to know what it does and how to finish it. My friend gave it to me for a challenge because I told him I knew javascript and I have no idea what it is.

 

package ConsoleApplication1;

import java.math.*;

import java.util.*;

import java.io.*;

 

/**

* Summary description for Program

*/

public class Program

{

public static void main(String[] args)

throws IOException

{

BufferedReader console = new BufferedReader(new InputStreamReader(System.in));

String input = console.readLine();

int i = 0;

String out = "";

int cof;

int power;

int l = input.length();

while (i <= l - 1)

{

 

cof = 0;

power = 0;

if (input.charAt(i) == '+')

{ out = ""; }

 

if (input.charAt(i) == 'x')

{

//shasfjdlkvhasjlkvhjklhlvhjlhvjashvjklhalashdvjklasdhvjklhghg

//System.out.println(out);

 

if (out == "cos")

{

System.out.print("-sin");

}

//asvdhjkasghdvjgvvhgggdjklshdjklsdhfjklshdfjklasdhflsdhflkah

try

{

cof = Integer.parseInt(out);

}

catch (NumberFormatException e) { }

 

i++;

 

if (input.charAt(i) == '^')

{

out = "";

i++;

while (input.charAt(i) != '+' && i <= l - 1)

{

out += input.charAt(i);

i++;

 

}

 

power = Integer.parseInt(out);

cof *= power;

power -= 1;

System.out.print(cof);

System.out.print("x^");

System.out.print(power);

if (i != l - 1)

{ System.out.print("+"); }

 

}

else

{

System.out.print(cof);

if (i != l - 1)

{ System.out.print("+"); }

}

out = "";

 

}

 

String f = "1";

int g;

 

//try

//{f+=input.charAt(i);

//g=Integer.parseInt(f);

out += input.charAt(i);//}

 

//catch (NumberFormatException e){}

 

 

i++;

 

 

}

 

input = console.readLine();

}

}

Link to comment
Share on other sites

My friend gave it to me for a challenge because I told him I knew javascript and I have no idea what it is.

 

Why did you take the challenge, if you knew nothing about the code your friend was challenging to complete? That wasn't very smart was of you to do. ???

 

This looks allot like vb.net to me; but I could be wrong - it's been a long time since I had that class in college. :D

 

Good Luck With Your Challenge! ;D

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.