Answer:
import java.util.Scanner;
public class Main
{
public static void main(String[] args) {
int[] arr = {4, 6, 9, 12};
int sum = 0;
for(int i=0; i<arr.length; i++){
sum += arr[i];
}
for(int i=0; i<arr.length; i++){
System.out.print(arr[i] + " ");
}
System.out.println("");
System.out.println("The sum of the numbers: " + sum);
}
}
Explanation:
* The code is written in Java.
- Initialize the array with the given numbers
- Initialize the <em>sum</em> variable as zero
- Calculate the sum in the first for loop
- Print the numbers in the second for loop
- Print the <em>sum</em>
Scalar Values are single numbers or values, which may include integers, floating-point decimals, or strings of characters.
A(n) array is a group of scalar or individual values that are stored in one entity.
A(n) user-defined type is a data type that is assigned a true or false value by a programmer.
A(n) abstract data type is a data type that can be assigned multiple values.
Answer:
I had a similar problem. I would suggest consulting someone professionally because thats what I had to do. I really dont know why it does that
Answer:
B) Punctuation
Explanation:
Punctuation are greatly used in different programming languages for different purposes. In the Java, C++ and C# Programming languages for example, two popular punctuation marks are the comma (,) and semi-colon (;). The comma is used for separating elements of a list and arrays, while the semi-colon indicates end of an executable statement or line of code. Other popular punctuation marks used in programming are periods (dot), question marks, parenthesis angle brackets and braces each implementing a specific grammatical syntax in the language.
Answer:
<u>Window.java</u>
- public class Window {
- int width;
- int height;
-
- public Window(int width, int height){
- this.width = width;
- this.height = height;
- }
- public int getWidth(){
- return width;
- }
- public int getHeight(){
- return height;
- }
-
- public int getClientAreaHeight(){
- return getHeight();
- }
- }
<u>Main.java</u>
- public class Main {
- public static void main (String [] args) {
- Window win1 = new Window(12, 15);
- System.out.println(win1.getClientAreaHeight());
- }
- }
Explanation:
<u>Window.java</u>
There is a Window class with two int type attributes, width and height (Line 1 - 3).
The constructor of this class will take two inputs, width and height and set these input to its attributes (Line 5 - 8). There are two methods getWidth and getHeight which will return the value of attributes width and height, respectively (Line 10 - 16).
The required new method getClientAreaHeight is defined in line 18 -20. This method will call the getHeight method to return the height value of the window (Line 19).
<u>Main.java</u>
We test the Window class by creating one Window instance and call the getClientAreaHeight method and print the return output (Line 1 -6).
We shall see 15 is printed.