OBJECT-ORIENTED PROGRAMMING. CS 102 Wednesday, 6 October, 2021 1. Write a Java program that creates two variables of type integer, named as num 1 and num 2. Get their values from user and then print the result of the following arithmetic operations in separate lines: a. Addition b. Subtraction c. Multiplication d. Division e. Remainder f. Average
Q: A. What are the types of Java Garbage Collectors [0.5 M] B. Identify and correct the errors in the…
A: A. What are the types of Java Garbage Collectors Answer: There are 4 types of garbage collectors:…
Q: Java - How do I output this statement as a horizontal statement with a newline? Everytime I use…
A: The answer is given below.
Q: Create a Java software that takes a character entered by the user and converts it to all capital…
A: Algorithm: Start Read array size n Read n characters and store them in an array Iterate through the…
Q: 6. What is the value of x after executing the following Java statements? int x = 2; x *= 2 + 3; а. 2…
A: Note: as per our guidelines we are supposed to answer?️ only one question. Kindly repost other…
Q: Design a class in C++, Java, and Python that represents complex numbers and Ji
A: Python program code for operator overloading: Output: //C++ program for operator overloading…
Q: 2.2 Identify the errors in the code below and re-write the correct program. Import…
A: Line Number Error Correction 1 Import import 1 JOptionpane JOptionPane 3 string String 5…
Q: // Step 1: Import the Java Scanner class /** * The Java program inputs the original cost for a sale,…
A:
Q: Which of the following statements is correct? In the modern day, CPUs have grown to enormous…
A: The electrical equipment that executes instructions in a computer program is known as a central…
Q: What will be the output of the following Python code? explanation ? def sayHello(): print('welocome…
A: Given Program:- What will be the output of the following Python code? explanation ? def…
Q: use Java. Moreover, i am a pythonist. So can u please write very detailed answer. For example…
A: It is defined as a powerful general-purpose programming language. It is used to develop desktop and…
Q: Problem 1: Write a java programming language that will accept string and display the length of…
A: A program is written in the java language. Where the program can be executes using any one of the…
Q: 1. What is printed by the Python code? def func(x): return x-1 print(func(3) *…
A: NOTE:“Since you have asked multiple questions, we will solve the first question for you. If you want…
Q: Develop a program that will read the following marks as inputs:…
A: Here, Program instructions are given.
Q: Use Python for this question: Craps is a single player dice game, that proceeds as follows:…
A: The python program is given by import random #function to calculate the sum of 2 dies def…
Q: PART A. Write a program NumberShape that asks the user to enter a single-digit number and outputs…
A: Program Explanation- Note- Your last four lines of the code are incorrect.The correct code is shown…
Q: No loops
A: The program is explained in detail with inlined comments. It uses the substring function of the…
Q: Write a Java program to reverse an array of integer values. PS: Please upload the output and say…
A: It is asked to provide the java program for reversing an integer array. A temporary array is used to…
Q: 1. Create a search method in your program that allows the user to find a tax payer and display their…
A: import java.util.Scanner; class Income { public static void main(String args[]) { double tax=0,it;…
Q: 4. Write and execute a JAVA program to accept three numbers from the user to evaluate the following…
A: #source code: import java.util.*; import java.lang.*; class Pattern{ public static void main(String…
Q: PROBLEM STATEMENT: Return the greatest of two numbers! Can you help mew with this question The…
A: According to the Question below the Solution: Output:
Q: Translate the following Java code into VM code. int positiveDivide(int a, int b) { int…
A: SOURCE CODE: VM Code:- int positiveDivide(int, int);Code:0: iconst_01: istore_32: iload_23: istore…
Q: I // Fig. 2.7: Addition.java 2 / Addition program that displays the sum of two numbers. 3 import…
A:
Q: 8. What will be the output of the following Java program?
A: To be determine: Select right option
Q: 8. Develop an application program in Java that can perform the following two operation. You have to…
A: As given, we need to write a Java program that perform the following operations - a) To check a…
Q: Write the flowchart of this code import java.io.*; import java.util.Scanner; public class…
A: The flowchart is a pictorial representation of the problem-solving steps. The steps in the flowchart…
Q: 1. Type the expressions below in python interactively, and try to explain what's happening in each…
A: Refer to step 2 for the answer.
Q: Extend to cast the double to an integer, and output that integer. Enter integer: 99 Enter double:…
A: Program: import java.util.Scanner; public class BasicInput { public static void main(String[]…
Q: Write, Compile and Execute a Java program based on a user-defined function that computes the sum of…
A: A user-defined function is a custom function that executes a set of program statements in a single…
Q: Q1. Write a java program to prompt the user to enter array of usernames then print them. Usernames=…
A: Steps to write the program: 1. First make the object for the scanner class. 2. Prompt the user to…
Q: Program 5: : Input first and last names and display the name in the format of last name, first name…
A: EXPLANATION: - The String variables for firstName and lastName are declared. To read the input from…
Q: Given an array of strings, write Java code to find the string that would come earliest in the…
A: To obtain a particular character at an index of a string we need to use the charAt(index) of the…
Q: using the java code below, create a new program that asks for Employees ID, then, takes the base pay…
A: As per the requirement program is completed. Note: Based on the employee table basepay and hours…
Q: Give a brief description of the problem (Specification and assumptions) of the program below.…
A: Please find code with comments below
Q: Take screenshots of your work a) Write a Java program, which prints numbers 1 to 10 then terminates.…
A: a. Code: public class MyClass { public static void main(String args[]) {…
Q: 1- Write a java Program to read a number from user and print full pyramid using numbers which will…
A: Refer to step 2 for the java program.
Q: 9. What is the length of the following array: byte[] data = { 12, 34, 9, 0, -62, 88 }; 10. What…
A: We are supposed to answer 1 question at a time, So I am solving the 10th question with the help of…
Q: Scanner(System.in); x = scan.nextInt(); y = scan.nextInt(); if(y >=…
A: The question has been answered in step2
Q: Painting a Room File Paint.java contains the partial program below, which when complete will…
A: The area to be painted will be 2*length*height+2*width*height= 2*height*(height+width)
Q: 1. Write a program that reads a Celsius degree in a double value from the console, then converts it…
A: Begin Take the celcius double value as input Compute the farhenheit Print value End
Q: The three possible ratings are 3, 2, 1 and they represent “Excellent”, “Good”, and “Poor”. An…
A: Requirement: Complete the given JAVA program to compute the raise of salary of the employee based…
Q: Consider the case of a Python program that does not work as expected because it displays the name of…
A: The above program gives output which is not correct and program executes successfully
Q: Write a Java program to solve the problem. Write a Java program that identifes whether a number is a…
A: SUMMARY: - Hence, we discussed all the points.
Q: this needs to be corrected The file provided in the code editor to the right contains syntax…
A: Required: this needs to be corrected The file provided in the code editor to the right contains…
Q: Java homework questions: Answer all exercises Not copied answer plzz Exercise 1 • Import and edit…
A: The code for the implementation of the the first program is as follows: import java.util.Scanner;…
Q: The file provided in the code editor to the right contains syntax and/or logic errors. In each case,…
A: Some syntactical and logical errors are there which have been resolved.Find error less code below
Q: PROBLEM STATEMENT: Add two numbers together and return the resulting sum. public class…
A: To write java program to add two numbers together and return the sum.
Q: Program below repeatedly accept real numbers until zero is entered. The output of the program is the…
A: Here is the complete java code of above problem. See below step.
Q: ram Năme ge.java Voltage.dat er asked you to write a program that will solve Voltage problems, using…
A: Code: import java.io.File;import java.io.IOException;import java.util.Scanner; public class…
Q: Create a java program using user defined function. Create a function/method void: -showinfo with…
A: public class Main{ public static void showinfo(int A1, String FN, String LN, String MI, int A2)…
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 1 images
- Java homework questions: Answer all exercises Not copied answer plzz Exercise 1 • Import and edit the Input04 project. • Run the code and examine the output. • Read through each next line until you find "BlueBumper". • The two numbers following "BlueBumper" are the object’s xPositon and yPosition. Store these coordinates as integers and print them. • Examine input04text.txt, if necessary. Input04.java package input04; import java.util.Scanner; public class Input04 { public static void main(String[] args){ Scanner sc = new Scanner(Input04.class.getResourceAsStream("input04text.txt")); //Edit these lines to advance the scanner sc.nextLine(); System.out.println(sc.nextLine()); //Does this line contain "BlueBumper"? System.out.println(sc.findInLine("BlueBumper")); //Store the next two numbers as xPosition and yPosition //Print these positions System.out.println("X: "…Please help create a searching algorithm for this java program. When a user enters the ceo name it displays their info such as their full names. Their company, salary, and tax owed Program is below import java.io.File; import java.io.FileNotFoundException; import java.io.FileWriter; import java.io.IOException; import java.util.ArrayList; import java.util.Scanner; public class Main { static public double calcTax(double salary, double taxRate) { double taxOwed = 0; taxOwed = (salary * taxRate) / 100; return taxOwed; } public static void main(String[] args) throws IOException { ArrayList salary = new ArrayList(); ArrayList name = new ArrayList(); ArrayList company_name = new ArrayList(); // int lines = 1; try{ File myFile = new File("taxpayer.txt"); Scanner fileReader = new Scanner(myFile); while(fileReader.hasNextLine()){ String data =…Java - How can I output the following statement as a single line with a newline? Program below. import java.util.Scanner; public class LabProgram { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); if(n>=11 && n<=100) { while(n>=11 && n<=100) { System.out.print(n+ " "); (the problem line. When I use System.out.println, it makes the line vertical when I want it horizontal.) if(n ==11||n==22||n==33||n==44||n==55||n==66||n==77||n==88||n==99) break; n--; } } else System.out.println("Input must be 11-100"); }}
- 4.34 LAB: Draw upside down triangle (JAVA) Write a program in java that outputs a right triangle of asterisks given the height as input. Each line ends with a blank space. Ex: If the input is: 3 the output is: * * * * * * Code starts here: import java.util.Scanner; public class LabProgram { public static void main(String[] args) { Scanner scnr = new Scanner(System.in); /* Type your code here. */ }}Java Questions - Based on each code, which answer out of the choices "A, B, C, D, E" is correct. Each question has one correct answer. Thank you. Part 1 - 6. Given the following code, the output is __. class Apple { int x = 15; }class Banana extends Apple { int x = 25; }public class Sample {public static void main(String[] args) {Apple a1 = new Banana();System.out.println(a1.x);}} A. Compiler errorB. 25C. 15D. 0E. None of the options Part 2 - 7. Which is possibly a composite class? class Seed { ... }class Fruit { Seed s1 = new Seed(); }class Apple extends Fruits { ... }class Orange extends Apple { ... }class ApplePie { ApplePie a1 = new ApplePie(); } A. FruitB. AppleC. ApplePieD. OrangeE. Seed Part 3 - 10. Given the following code, which statement is true? class Water() { ... }class Juice() extends Water { ... }class Apple() { ... }class ApplePie() { Apple a1 = new Apple(); }class AppleJuice() { Apple a1 = new Apple(); Water w1 = newWater(); } A. Juice is a superclass and Water is a…Preffered language is java. Will be compiled with intellij Problem 1 consists of multiple parts. You should finish one part and ensure that it works before moving to the next part. You will need to refactor (rewrite parts of) your code as you move between parts. Part 1 The use of computers in education is referred to as computer-assisted instruction (CAI). Write a program that will help an elementary school student learn multiplication. Use a SecureRandom object to produce two positive one-digit integers (you will need to look up how to do this). The program should then prompt the user with a question, such as How much is 6 times 7? The student then inputs the answer. Next, the program checks the student’s answer. If it’s correct, display the message "Very good!" and ask another multiplication question. If the answer is wrong, display the message "No. Please try again.>again." and let the student try the same question repeatedly until the student finally gets it right. A separate…
- hi, why my code when i try to calculate BMI every time the answer equal 0.0 and can't get the right answer? package a;import java.util.*;public class a { public static void main(String []args){Scanner sc=new Scanner(System.in);label:System.out.println("Enter the number of cities");int noOfcities,nPerson;noOfcities=sc.nextInt();int under=0,obese=0,normal=0,over=0,c_under=0,c_obese=0,c_normal=0,c_over=0;double p_under,p_over,p_obese,p_normal;double max_normal=0.0,max_obese=0.0,min_under=100.0;String name,b_city="None",w_city="None",u_city="None",cat;int mass,height; while ( noOfcities<6){System.out.println("erro");System.out.println("Enter the number of cities"); noOfcities=sc.nextInt();}int i=0;while (i<noOfcities){i++;System.out.println("Enter the name of city");name=sc.next();System.out.println("Enter the number of persons");nPerson=sc.nextInt();while (nPerson<10){System.out.println("eror");System.out.println("Enter the number of…JAVA - Please produce both a product.java file and a productprinter.java file (tester) Implement a class Product. A product has a name and a price, for example new Product("Toaster", 29.95). Supply methods getName, getPrice, and reducePrice. Supply a program ProductPrinter that makes two products, prints each name and price, reduces their prices by $5.00, and then prints the prices again.java السؤال the following code has a syntax error Figure out the error and correct it ? class access { public int x; static int y; void cal(int a, int b) { x += a ; y += b; } } class B{ final int AGE = 32; AGE = 45; System.out.println ("Age: " + AGE); } }
- Modify the command-line argument example Hello.java, to handle a few command-line arguments. Ask the user to enter a name followed by a number. The program should print out the name N times, while N is the input number. For example, if the command-line input is Java Hello Jim R. Joseph 5 Then the output should be: Jim R. Joseph Jim R. Joseph Jim R. Joseph Jim R. Joseph Jim R. Joseph Now what I got was this which is incorrect import java.util.Scanner;public class Main{ public static void main(String[] args) { Scanner input = new Scanner (System.in); System.out.print("Enter the name: "); String name = input.nextLine(); System.out.print("Enter the value of n: "); int num = input.nextInt(); int j = 0; while(j < num){ System.out.println(name); j++; } }} But the correct way to do it is to use the command-line arguments to send in the name and number, instead of the Scanner. So you can retrieve the name from args[0]…Java - How do I output this statement as a horizontal statement with a newline? Everytime I use System.out.println, it makes the entire output vertical instead of horizontal. Program below. import java.util.Scanner; public class LabProgram { public static void main(String[] args) { int x; int y; Scanner scan = new Scanner(System.in); x = scan.nextInt(); y = scan.nextInt(); if(y >= x){ for(int i=x; i<=y; i = i + 5) { System.out.print(i+ " "); (The problem line) } } else{ System.out.print("Second integer can't be less than the first."); } }}Need help with java problem. Start with the java file below and add the following methods:1. Add the methodpublic int getLastIndex(T item) which returns the index of the last entry which is equal to item. If item is not found, it returns -1. 2. Add the method public boolean equals(Object other) that returns true when the contents of 2 objects are the same. java file: