Syntax: keywords Procedural processing example / class Main ( Inputs some numbers and computes their average / function void main() { var Array a; var int length; var int i, sum; let length Keyboard.readInt("How many numbers? "); let a Array.new(length); // constructs the array let i 0; while (i Operators. Translate the following Java code into its equivalent Jack code. int x = 3; int y = 5; int greatest; if (x > y) else greatest = x; greatest = y; System.out.println(greatest); // Multiplies x * y // (by summing x, y times) int x = 2; int y = 5; int product = 0; int n = 1; while (ny) { product + x; n++; } System.out.println("The product is " + product); Jack Code Jack Code

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter2: Using Data
Section: Chapter Questions
Problem 14RQ
icon
Related questions
Question

Please help me translate the java code to jack code

Syntax: keywords
Procedural processing example /
class Main (
Inputs some numbers and computes their average /
function void main() {
var Array a;
var int length;
var int i, sum;
let length Keyboard.readInt("How many numbers? ");
let a Array.new(length); // constructs the array
let i 0;
while (i<length) {
Syntax elements:
White space/comments
⚫ keywords
Symbols
Constants
let a[i]
Keyboard.readInt("Enter a number: ");
let sum sum a[i];
• Identifiers
let i 11;
}
}
Syntax: symbols
Procedural processing example */
class Main (
Inputs some numbers and computes their average */
Syntax elements:
function void main() {
var Array a;
var int length;
var int i, sum;
let length Keyboard.readInt("How many numbers? ");
leta Array.new(length); // constructs the array
.
White space/comments
⚫ keywords
• Symbols
let i=0;
while (1
length) {
⚫ Constants
let a[i]
Keyboard.readInt("Enter a number: ");
let sum sum a[i];
leti i 1;
• Identifiers
}
class, constructor, method, function
Program components
Primitive types
int, boolean, char, void
var, static, field
let, do, if, else, while, return
true, false, null
this
Variable declarations
Statements
Constant values
Object reference
() Used for grouping arithmetic expressions and
for enclosing parameter-lists and argument-lists;
[] Used for array indexing;
{) Used for grouping program units and statements;
Variable list separator;
Statement terminator;
Assignment and comparison operator;
Class membership;
+ / &<> Operators.
Translate the following Java code into its equivalent Jack code.
int x = 3;
int y = 5;
int greatest;
if (x > y)
else
greatest = x;
greatest = y;
System.out.println(greatest);
// Multiplies x * y
// (by summing x, y times)
int x = 2;
int y = 5;
int product = 0;
int n = 1;
while (ny)
{
product + x;
n++;
}
System.out.println("The product is "
+ product);
Jack Code
Jack Code
Transcribed Image Text:Syntax: keywords Procedural processing example / class Main ( Inputs some numbers and computes their average / function void main() { var Array a; var int length; var int i, sum; let length Keyboard.readInt("How many numbers? "); let a Array.new(length); // constructs the array let i 0; while (i<length) { Syntax elements: White space/comments ⚫ keywords Symbols Constants let a[i] Keyboard.readInt("Enter a number: "); let sum sum a[i]; • Identifiers let i 11; } } Syntax: symbols Procedural processing example */ class Main ( Inputs some numbers and computes their average */ Syntax elements: function void main() { var Array a; var int length; var int i, sum; let length Keyboard.readInt("How many numbers? "); leta Array.new(length); // constructs the array . White space/comments ⚫ keywords • Symbols let i=0; while (1 length) { ⚫ Constants let a[i] Keyboard.readInt("Enter a number: "); let sum sum a[i]; leti i 1; • Identifiers } class, constructor, method, function Program components Primitive types int, boolean, char, void var, static, field let, do, if, else, while, return true, false, null this Variable declarations Statements Constant values Object reference () Used for grouping arithmetic expressions and for enclosing parameter-lists and argument-lists; [] Used for array indexing; {) Used for grouping program units and statements; Variable list separator; Statement terminator; Assignment and comparison operator; Class membership; + / &<> Operators. Translate the following Java code into its equivalent Jack code. int x = 3; int y = 5; int greatest; if (x > y) else greatest = x; greatest = y; System.out.println(greatest); // Multiplies x * y // (by summing x, y times) int x = 2; int y = 5; int product = 0; int n = 1; while (ny) { product + x; n++; } System.out.println("The product is " + product); Jack Code Jack Code
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Similar questions
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781305480537
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning