Docsity

Java Programming Exercises and Solutions, Exams of Biology

Toggle sidebar
bg1
CSCI 2350 Programming and
Data Structures fully solved
2025(graded A+)
What is the name of this file?
public class Exercise01_02 {
public static void main(String[] args) {
//Display message Welcome to Java five times on the console
System.out.println("Welcome to Java");
System.out.println("Welcome to Java");
System.out.println("Welcome to Java");
System.out.println("Welcome to Java");
System.out.println("Welcome to Java");
}
} - answer Exercise01_02
What is wrong with the naming of this file?
public class exercise01_02 {
public static void main(String[] args) {
//Display message Welcome to Java five times on the console
System.out.println("Welcome to Java");
System.out.println("Welcome to Java");
System.out.println("Welcome to Java");
System.out.println("Welcome to Java");
System.out.println("Welcome to Java");
}
} - answer It is not capitalized.
pf3
pf4
pf5
pf8
pf9
pfa

Partial preview of the text

Download Java Programming Exercises and Solutions and more Exams Biology in PDF only on Docsity!

CSCI 2350 Programming and

Data Structures fully solved

2025(graded A+)

What is the name of this file? public class Exercise01_02 { public static void main(String[] args) { //Display message Welcome to Java five times on the console System.out.println("Welcome to Java"); System.out.println("Welcome to Java"); System.out.println("Welcome to Java"); System.out.println("Welcome to Java"); System.out.println("Welcome to Java"); } } - answer Exercise01_ What is wrong with the naming of this file? public class exercise01_02 { public static void main(String[] args) { //Display message Welcome to Java five times on the console System.out.println("Welcome to Java"); System.out.println("Welcome to Java"); System.out.println("Welcome to Java"); System.out.println("Welcome to Java"); System.out.println("Welcome to Java"); } } - answer It is not capitalized.

Which word is not capitalized but should be? public class Exercise01_02 { public static void main(string[] args) { //Display message Welcome to Java five times on the console System.out.println("Welcome to Java"); System.out.println("Welcome to Java"); System.out.println("Welcome to Java"); System.out.println("Welcome to Java"); System.out.println("Welcome to Java"); } } - answer String Select the missing punctuation marks. public class Welcome __ public static void main __ String __ __ args __ __ System.out.println __ __ Welcome to Java __ __ __ __ __ - answer { ( [ ] ) { ( " " ) ; } } What words below are keywords? public class Welcome { public static void main(string[] args) { //Display message Welcome to Java on the console

Order the following program correctly so that it creates a Scanner object, prompts the user to enter a radius, computes area, and displays the result. public class ComputeArea { radius + " is " + area); double area = radius *(asterisk) radius *(asterisk) 3.14159; System.out.print("Enter a number for radius: "); import java.util.Scanner; public static void main(String[] args) { } } System.out.println("The area for the circle of radius " + Scanner input = new Scanner(System.in); double radius = input.nextDouble(); - answer import java.util.Scanner; public class ComputeArea { public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.print("Enter a number for radius: "); double radius = input.nextDouble(); double area = radius *(asterisk) radius *(asterisk) 3.14159; System.out.println("The area for the circle of radius " + radius + " is " + area); } } Identifiers can be which of the following: contain letters contain digits contain underscores (_)

contain dollar signs ($) can start with a letter can start with a digit can start with an underscore () can start with a dollar sign ($) can be a reserved word - answer contain letters contain digits contain underscores () contain dollar signs ($) can start with a letter can start with an underscore (_) can start with a dollar sign ($) The following is a sequence of lines in a program. After each line below, determine the value assigned to the variable: int r = 2; // r = __ double area = 5.0; // area = r = r + 1; // r = __ double circumference = 6.28 * r; //circumference = __ 5 = r; // r = __ - answer 2

3

error

  1. The number of dollars is calculated by 78/100 = __ and the number of cents is calculated by 78%100 = __.
  2. The number of quarters is calculated by 78/25 = __ and the number of cents is calculated by 78%25 = __.
  3. The number of dimes is calculated by 78/10 = __ and the number of cents is calculated by 78%10 = __.
  4. The number of nickels is calculated by 78/5 = __ and the number of cents is calculated by 78%15 = __. - answer 0, 78 3, 3 7, 8 15, 3 Match the code to the question it answers. Is the integer even? Is the integer odd? What day of the week will it be? How many weeks will it be? - answer n % 2 = 0 n % 2 = 1 d % 7 d / 7 cost is 1293. discountRate is 0. discount is cost times discountRate

discount = cost * discountRate; __ discount = cost * discountRate * 100; __ discount = (int) cost * discountRate * 100; __ discount = (int) (cost * discountRate * 100); __ discount = (int) (cost * discountRate * 100) / 100; __ discount = (int) (cost * discountRate * 100) / 100.0; __ discount = (int) (cost * discountRate * 10) / 10.0; __ - answer

25860 25868 258

Order the stages of the software development process. System Analysis Testing Requirement Specifications Maintenance System Design Deployment Implementation - answer Requirement Specifications System Analysis System Design Implementation Testing

public class EvenOdd { public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.print("Enter a number: "); int number = input.nextInt(); if (number % 2 == 0) System.out.println(number + " is even."); else System.out.println(number + " is odd."); } } What range of integers do the following lines of code produce? int guess1 = (int)(Math.random() *10); // from __ to __ int guess2 = (int)(Math.random() *10) + 1; // from __ to __ int guess3 = (int)(Math.random() *50); // from __ to __ int guess4 = (int)(Math.random() *11) + 50; // from __ to __ - answer 0, 9 1, 10 0, 49 50, 60 Put the code for swap in order: second = temp; int temp = first; first = second; - answer int temp = first; first = second; second = temp;

Truth Table for Operator! p --> !p false --> __ true --> __ - answer true false Truth Table for Operator && p1 p2 --> p1 && p true true --> __ true false --> __ false true --> __ false false --> __ - answer true false false false Truth Table for Operator || p1 p2 --> p1 || p true true --> __ true false --> __ false true --> __ false false --> __ - answer true true true false Truth Table for Operator ^ p1 p2 --> p1 ^ p