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
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
Chapter2: Using Data
Section: Chapter Questions
Problem 14RQ
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](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F46c0fb16-724b-4726-818c-9156075ac6cc%2Ffded0b74-7f51-4cd2-825b-7a6fc780ee2b%2Fed6be9_processed.jpeg&w=3840&q=75)
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

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 2 steps

Recommended textbooks for you

EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT

Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,

C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr

EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT

Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,

C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr

EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781305480537
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage

C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning