The Artima Developer Community
Sponsored Link

Java Answers Forum
convert java to pseudocode

3 replies on 1 page. Most recent reply: May 31, 2005 6:12 AM by barron

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 3 replies on 1 page
ammy

Posts: 1
Nickname: amfoxlady
Registered: May, 2005

convert java to pseudocode Posted: May 30, 2005 9:07 PM
Reply to this message Reply
Advertisement
I'm writing a program that allows the user to convert a line of java into pseudocode, so far, I've got the following:

import element.*;
public class a {
  public static void main(String[] args) {
    ConsoleWindow c = new ConsoleWindow();  // opens console window
    String inputLine, outputLine;
    c.out.println("Enter a line");
    inputLine = c.input.readString();
 
    c.out.println("You have entered: "+ inputLine);
 
     if (inputLine.endsWith(";"));
    {outputLine="Is a java line";
    c.out.println(inputLine + " is a valid line of java");}
 
 
 
    if (inputLine.startsWith("int"))        //if the input is an int expression
    {outputLine="This is an integer datatype";
    c.out.println("This is an integer datatype");} //this will come out
 
    if (inputLine.startsWith("double"))      //double
    {outputLine="This is a double number datatype";
    c.out.println("This is a double number datatype");}
 
    if (inputLine.startsWith("long"))      //long
   {outputLine="This is a long integer datatype";
    c.out.println("This is a long integer datatype");}
 
    if (inputLine.startsWith("short"))      //short
    {outputLine="This is a short integer datatype";
    c.out.println("This is a short integer datatype");}
 
    if (inputLine.startsWith("char"))      //char
    {outputLine="This is an alphabetical character datatype";
    c.out.println("This is an alphabetical character datatype");}
 
    public ArithmeticException ("+", "-", "/", "*")
    
    }
  }


Somebody suggested me to use strings as well, but I don't quite understand how to get around to using it.


Kondwani Mkandawire

Posts: 530
Nickname: spike
Registered: Aug, 2004

Re: convert java to pseudocode Posted: May 31, 2005 12:33 AM
Reply to this message Reply
Checkout posting by Elise:
HELP - converting characters,

I've given a suggestion on how to go about
it. Just a Q: you have imported a package
called element, if you are at the level
where you are writing your own packages,
this should be a trivial algorigthm for
you, shouldn't it? Or am I misunderstanding
the problem?

barron

Posts: 13
Nickname: toniblair
Registered: May, 2005

Re: convert java to pseudocode Posted: May 31, 2005 6:04 AM
Reply to this message Reply
It looks to me, as though he hasn't written the package element himself, but rather uses it to take care of basic i/o functionality. e.g. the 'ConsoleWindow' object may be a class from within the element package.

barron

Posts: 13
Nickname: toniblair
Registered: May, 2005

Re: convert java to pseudocode Posted: May 31, 2005 6:12 AM
Reply to this message Reply
Sorry Ammy I meant 'she' not 'he'.

You could improve your code by actually using the variable outLine in your code. For example:

use:

if (inputLine.startsWith("int"))
{
outputLine="This is an integer datatype";
c.out.println(outputLine);
}

not:


if (inputLine.startsWith("int"))
{outputLine="This is an integer datatype";
c.out.println("This is an integer datatype");}

Flat View: This topic has 3 replies on 1 page
Topic: tomcat is not startup when clickinon startup.bat Previous Topic   Next Topic Topic: Subversion - Eclipse - Subclipse - JavaSVN

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use