[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 223
  • Last Modified:

Visual basic - simple beginner program question

I have a friend writing a entry level VB app but I do not know VB - can you correct the following code? Looks like a VERY simple calculator...

Andrea Cortez
 * CS123-0804A-04
 * Problem Solving and programming Concepts
 * Jeffrey Unger
 * Colorado Technical University Online
 * November 2, 2008
 */
package lab4;
import java.util.Scanner;

/**
 *
 * @author MandaPiggy
 */
public class Main {
    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // int a, b, c, d, x;
        int n1, n2;
       
        Scanner keyboard = new Scanner (System.in);
        // This is the starting of the program//
        System.out.println("Please enter first number:");
        // This is the first step in the program//
        n1 = keyboard.nextInt();
        // This is how the program will read the first step//
        System.out.println("Choose a letter:");
       
        if (a = add) {
           then (n1 + n2 = x);
        }else if (b = subtract) {
           then (n1 - n2 = x);
        }else if (c = multiply) {        
           then (n1 * n2 = x);
        }else if (d = divide) {
           then (n1/n2 = x);
         class.lab4.Main();
       
        }
        System.out.println ("Enter second number:");
        n2 = keyboard.nextInt();
        System.out.println ("The total is" + (n1 + n2));  
       
    }
}
init:
deps-jar:
Compiling 1 source file to C:\Documents and Settings\MandaPiggy\My Documents\NetBeansProjects\Lab4\build\classes
C:\Documents and Settings\MandaPiggy\My Documents\NetBeansProjects\Lab4\src\lab4\Main.java:42: <identifier> expected
         class.lab4.Main();
C:\Documents and Settings\MandaPiggy\My Documents\NetBeansProjects\Lab4\src\lab4\Main.java:42: <identifier> expected
         class.lab4.Main();
C:\Documents and Settings\MandaPiggy\My Documents\NetBeansProjects\Lab4\src\lab4\Main.java:50: reached end of file while parsing
}
3 errors
BUILD FAILED (total time: 0 seconds)

Thanks!
0
Karl66
Asked:
Karl66
1 Solution
 
GrahamSkanCommented:
The main problem is that the code isn't VB.
It looks like Java. Or is could be JavaScript, C# or one of those languages with syntax derived from C.
0
 
vbsquickresponseCommented:
Do you want this program to rewritten in VB?  Looking at the code its looks like java code to me!

What add, substract, multiply means in the code? have u declare them somewhere or they are keywords?

        if (a = add) {
           then (n1 + n2 = x);
        }else if (b = subtract) {
           then (n1 - n2 = x);
        }else if (c = multiply) {        
           then (n1 * n2 = x);
        }else if (d = divide) {

error shown becz of them might be!
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now