public class IncrementDecrement { public static void main (String[] args) { int number = 50; int numberl = 0; int number2 = 0; // Display the value in number. "Number is " + number); // Increment System.out.println( number. // Display the value in numberl=number++; number. System.out.println( "Now, number is " + number); // Decrement number. // Display the value in number. System.out.println("Now, number is + number); number2=number-- System.out.println("Now, number is " System.out:println("Now, number is + number1); " + number2); }}
Q: public class MyOutput { public static void main(String[] args) { int totalNumbers=6; Double…
A: Given int totalNumber=6 double dblAverage=4.5 Integer yourNumber = new Integer(20);//Wrapper class…
Q: public class MyScope { static int value 2; public static void main (String[] args) {…
A: The program execution begins from the main function. The main function starts as follows -…
Q: class operators { public static void main(String args[]) {…
A: output for the code: public static void main(String args[]) { int x = 8;…
Q: public class IceCream extends ConsoleProgram public void run() { // write code here }
A: Java programming language is an object-oriented programming language, that's used to develop web…
Q: Java --- Please help me understand further the code below. Thank you!| --- Circle.java public class…
A: ALGORITHM: Step 1: Create an interface Shape Step 2: In that create 4 classes circle, rectangle,…
Q: JAVA PROGRAMMING Please Help! Look over my code and explain to me what I'm doing wrong. Thank You!…
A: Here, I have to write a java code for the above question. The highlighted one is the modified code.
Q: public class Test { public static void main(String[] args) { Number x = new Integer (3);…
A: //we are getting the error because X is an Number and new Integer is an integer so we are not able…
Q: public class FirstEx_2ExplainCode static int counterObj= 0; public double salary = 0; public static…
A: public class FirstEx_2ExplainCodes { static int counterObj = 0; public double salary = O;…
Q: Subject - Data Structure Please help me to debug my error. Thank you in advance! import…
A: I give the required error-free code along with output and code screenshot
Q: public class output{ public static int find (int a1, int a2) if(al==0) return(al+1); else if(a1>0 &&…
A: Explanation:- 1. Initially both a1 and a2 value is 2. 2. Then the else condition will be hit for the…
Q: Write java program that has two class the main class and calculator class. The program receive two…
A: /* package codechef; // don't place package name! */ import java.util.*;import java.lang.*;import…
Q: don't use others answers java Given the Baby class below write an equals method for the Baby…
A: The problem is based on the basics of OOPS in java programming language.
Q: In Java, how do you make an Average calculator using this source code: import java.util.Scanner;…
A: As the source code is already provided in the question including integer variables and a double for…
Q: Please help me in fixing the errors in this java program.
A: solution in below step
Q: In C++ class rectangleType { public: void setLengthWidth(double x, double y); //Sets the…
A: A C++ program to compute the area and perimeter of a rectangle using class structure.
Q: public class Main { public static void main(String[] args) { int result = sum(10, 10);…
A: Given Java program
Q: class Output { public static void main(String args[]) { Integer i = new Integer(557); float x =…
A: Given, The programming language used = JAVA Code: class Output { public static void…
Q: Java Palindrome Detector A palindrome is any word, phrase, or sentence that reads the same…
A: Algorithm: Start Declare a string variable. Read a string Call a recursive function to check…
Q: Complete the following Java program so that it prompts the user for a series of numbers to determine…
A: The code is given below.
Q: Write java program for the following class diagram . The Instructions: 1. This java program is for…
A: We will write java code to solve the given problem.
Q: An anagram is a word that has been rearranged from another word, check to see if the second word is…
A: output
Q: In C++ class rectangleType { public: void setLengthWidth(double x, double y); //Sets the…
A: The problem is based on the basics of classes in C++ programming language.
Q: ROBLEM STATEMENT: Square a number and return the resulting product. public class SquareANumber{…
A: The given problem is related to Java programming where the function is to be implemented named…
Q: Find the errors in this code: public class TstArray { public static void main(String args[]){…
A: The error in the above code is only just that at the time of declaration of variable total it has…
Q: public class EscapeSequences { public static void main( String args[] ) { // Add a tab between…
A: Code public class EscapeSequences { public static void main(String args[]){ System.out.println("He…
Q: Fill with appropriate java keywords/syntaxes in the following method overloading program. package…
A: The modified code the output has been given in step 2.
Q: Math: pentagonal numbers) A pentagonal number is defined as n(3n-1)/2 , for n = 1,2, . . ., and so…
A: Pentagon Class: Pentagon Class contains calcPentagonalNumber() definition which returns pentagonal…
Q: public class Main5 public static void main(String] args) { int a = 5; int b = 6, float c = alb,…
A: The answer is as follows:-
Q: Please correct the error, I don't know where I mistake. currently it says I've mistake at…
A: Given: Please correct the error, I don't know where I mistake. currently it says I've mistake at…
Q: public class Test { public static void main(String args[]) int x = 5; int y = 9;…
A: int x = 5; int y = 9; System.out.println(" " + ++y) // output "10" because it is pre…
Q: public class Main { public int a; public long b; public void test(long b) { System.out.println("long…
A: In Java, int takes values from -2,147,483,648 to 2,147,483,647
Q: Accumulating Totals in Single-Level Control Break Programs Summary In this lab, you will use what…
A: According to the information given:- we have to follow the instruction to get desired outcome.
Q: public class ReportSum { public static void main(String args[]) { //assume we have 2 numbers a and…
A: Here I have created a function named sum2Numbers(). In this function, I have calculated the sum of…
Q: [Repost] Instructions: (USE JAVA LANGUAGE) Kindly modify, add on where it is lacking and execute the…
A: I am going to edit the code and add the output of it below.
Q: class Test{ public static void main(String[] args) { int number=9; double variable=D1.5;…
A: The problem is based on the basics of java programming language.
Q: Need help with following Java method: import java.util.Scanner; import java.lang.Math; public class…
A: The program uses the Scanner package which is used for taking user inputs during run time. The next…
Q: PROBLEM STATEMENT: Return the longest String! public class LongestString{ public static String…
A: To Do: To complete the code.
Q: public class Main5 { public static void main(String[] args) { int a = 5; int b = 6, float c = a/b,…
A: You Can Use Type Casting .since a ,b is int type and c is float so you explicit tell the compiler…
Q: The output of the above Java code is ?
A: Given, Code: class Output { public static void main(String args[]) { byte a[] = { 65, 66, 67,…
Q: public class Test { } public static void main(String[] args) { int a = 10;…
A: The output of the above code will be
Q: public class Test { } public static void main(String[] args) { String str = "Salom";…
A: S
Q: public class Main { public static void main(String[] args) { System.out.println("Your…
A: Algorithm :- 1 - start 2- read number n 3- call factorial 4- print factorial factorial(number) 1- if…
Q: PROBLEM STATEMENT: Return a number, 1 lesser than the given number. public class Decrement{…
A: Here I have created a function named solution (). This function has one input parameter. Inside this…
Q: Programming Exercise 3-9 Instructions Insurance.java 1 import java.util.Scanner; class Insurance {…
A: import java.util.Scanner;public class Insurance{ public static void main(String[] args) { // Write…
Q: public class Test { private int t; public static void main(String] args) { int x;…
A: Please give positive ratings for my efforts. Thanks. ANSWER Here, in the above program, t is…
Q: Java Questions - (Has 2 Parts). Based on each code, which answer out of the choices "A, B, C, D, E"…
A: Answer:
Q: } class Driver { public static void main(String[] args) { int a = 6; int b = 6; int c = 5; int x =…
A: Here is the given java code : class Driver { public static void main(String[] args) { int a = 6;…
Q: public class TestAnimal { public static void main(String[] args){ display(new Dog(); display(new…
A: We need to implement the Animal, Dog, Lion, and Bulldog classes as per the given description.
Q: JAVA The method takes a string as a parameter. The method prints treat if the string is candy or…
A: Here, first you need to create "Scanner" class object in main() function for taking input from user.…
Run the following code. Write its output and also explain the output
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 3 images
- In C++ class rectangleType { public: void setLengthWidth(double x, double y); //Sets the length = x; width = y; void print() const; //Output length and width double area(); //Calculate and return the area of the rectangle (length*width) double perimeter(); //Calculate and return the perimeter (length of outside boundary of the rectangle) private: double length; double width; }; Print out the area of the rectangle.**JAVA LANGUAGE** beginner level import java. util.Arrays;import java.util.Scanner; Suppose that a Scanner object contains a bunch of tokens all on a single line separated by spaces. For example: 100.5 30.4 pizza 56.8 1000.3 8.2 Also suppose that you have a particular item that you know the price of. Let’s use the following example: Kindle: 99.99 Write a static method: public static double priceIsRight(Scanner s, double price) that takes a Scanner and an item price as parameters and returns the bid that is closest to the item price but not greater than the item price. If all bids are greater than the price, return 0.0. If there are no bids (Scanner is empty) return 0.0. You can assume the Scanner is not null. In the above example. 56.8 should be returned, since it is the number that is closest to 99.99 but not over 99.99. Notice that there may be some invalid tokens in the Scanner's input. The above example has pizza as one of its tokens, which is clearly not a valid bid. Your…In C++ class rectangleType { public: void setLengthWidth(double x, double y); //Sets the length = x; width = y; void print() const; //Output length and width double area(); //Calculate and return the area of the rectangle (length*width) double perimeter(); //Calculate and return the perimeter (length of outside boundary of the rectangle) private: double length; double width; }; Declare an instance of rectangleType.
- import java.util.*; public class CardGame { static Scanner scanner = new Scanner(System.in); static Random random = new Random(); public static void main(String[] args) { System.out.println("Welcome to the card game! Here are the instructions:"); System.out.println("- You will randomly draw a card from a deck of 52 cards."); System.out.println("- The computer will also draw a card from the same deck."); System.out.println("- If your card has a higher face value, you win. Otherwise, you lose."); System.out.println("- If your card has the same face value as the computer's card, the suit determines the order."); int gamesPlayed = 0; int userWins = 0; int computerWins = 0; boolean[] cards = new boolean[52]; // false means the card is available, true means it's been drawn while (true) { System.out.println("\nNew game!"); int[] userCard = drawCard(cards); int[]…JAVA PROGRAMMING Please Help! Look over my code and explain to me what I'm doing wrong. Thank You! This is my code so far : package initials; import java.util.Random; public class Initials { public static void main(String[] args) { //Create a new array of Strings named strings with the following line of code: //String[] strings = {"Henry Lane Van", "Jakie Marie Johnson", "Oliver Ian Smith", //"Lucas James Whitaker","Billy Bob Washington"}; String[] strings = {"Henry Lane Van", "Jakie Marie Johnson", "Oliver Ian Smith", "Lucas James Whitaker","Billy Bob Washington"}; //Create a for loop to step through the array with the following form "for (int i=0;i<strings.length;i++)" for (int i=0;i<strings.length;i++) { //The following goes in the loop: //Set a new String variable named currentName to "[Henry Lane Van]" String currentName = new String("Henry Lane Van"); //Output…Instructions: (USE JAVA LANGUAGE) Kindly modify, add on where it is lacking and execute the java program provided below. Don't forget to provide a screenshot of the program output. House.java import java.awt.*; public class House { private static int MID; private static int TOP; public House(int m, int t) { MID = m; TOP = t; } public void draw(Graphics g) { g.setColor(new Color(60, 0, 0)); g.fillRect(MID-100, TOP+70, 200, 90); drawChimney(g); drawRoof(g); drawDoor(g); drawWindow(g); } private void drawRoof(Graphics g) { Polygon p = new Polygon(); g.setColor(Color.RED); p.addPoint(MID-100, TOP+70); p.addPoint(MID, TOP); p.addPoint(MID+100, TOP+70); g.fillPolygon(p); } private void drawDoor(Graphics g) { g.setColor(Color.WHITE); g.fillRect(MID-60, TOP+120, 20, 40); } private void drawWindow(Graphics g) { g.setColor(Color.CYAN); g.fillRect(MID+20, TOP+80, 20, 20); } private void drawChimney(Graphics g) { g.setColor(Color.ORANGE); g.fillRect(MID+60, TOP+10, 20, 50);…
- Write java program for the following class diagram . The Instructions: 1. This java program is for an application that stores the author (Writer) data of some books and emails. 2. getAuthors() method get the list of authors and store it in a String array. 3. addAuthors() method is used to add an author anytime for book or email. 4. getDate() method get the date of the book or email. 5. getTitle() method can be used to get the title of the book. 6. getSubject() method is used to get the Subject of the email. 7. getTo() method is used to get the information about the mail to whom it is sent. 8. All get methods need to return the values in the corresponding instance variables. 9. Scanner class can be used to set the data for the variables. The programmer can give his/her own methods to set the instance variables.Java Questions - (Has 2 Parts). 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 - 3. Given the following code, the output is __. class Base { private int x = 5; }class Derived extends Base { x = 6; }public class Sample { public static void main(String[] args) { int x = 7; Derived d1 = new Derived(); System.out.print(d1.x); }} A. 0B. 5C. 6D. 7E. Error message Part 2 - 4. A class Animal has a subclass Mammal. Which of the following is true? A. class Animal extends Mammal { }B. class Mammal extends Animal { }C. class Animal implements Mammal { }D. class Mammal implements Animal { }E. class Mammal { Animal a1 = new Animal(); }Java Language Please help me fix all the error. I very appreciate it Coding: import java.util.Scanner;public class Main { /*static displayline(); char line; { for (int i = 1; i < line; i++ ) { System.out.println ("_"); } } */ public static void main(String[] args) { System.out.println("Clinic Management\n"); int PatAge, Pnumber,age; int cmedicine, cost, Pcost, total, newTotal; String PatName, Pgender, Pdisease, Pmedicine; char typeofmedicine; Scanner scan = new Scanner(System.in); System.out.println("Patient Name :"); String name = scan.next(); name = name + scan.nextLine(); System.out.println("Patient Age :"); age = scan.nextInt(); System.out.println("Patient Gender :"); String gender = scan.next(); System.out.println("Patient Phone Number :"); Pnumber = scan.nextInt(); System.out.println("Patient Disease :" ); String disease =…
- please help with this Java Lab. This is what i have so far public static void main(String[] args) { // TODO Auto-generated method stub // Getting user input for num of servings Scanner kb = new Scanner(System.in); System.out.println("How many serving would you like to make?"); int servings = kb.nextInt(); //initialize other variables double batch = servings /9; }//end of main method public static int calcPeaches(int batch) { int peaches = batch *29; return peaches; }//end of calcPeaches public static double calcButter(double batch) { double butter = (3/8)*batch; } }public class worksheet3_1 { public static void main(String[] arg) { ShadowingExample example = new ShadowingExample(); example.x = 99; example.sampleMethod(); }}class ShadowingExample { int x; public void sampleMethod() { int x = 0; System.out.println("the value of local variable x = " + ………………………………………………); System.out.println("the value of instance variable x = " + …………………………………………); }} what should be written in the second print statement so that the output is: the value of instance variable x = 99 what should be written in the first print statement so that the output is: the value of local variable x = 0 options are: samplemethod.x this.x shadowingexample.x x Answer 1 Question 1public class LabProgram { public static void main(String args[]) { Course cis162 = new Course(); int beforeCount; String toDrop; // Example students for testing cis162.addStudent(new Student("Henry", "Nguyen", 3.5)); cis162.addStudent(new Student("Brenda", "Stern", 2.0)); cis162.addStudent(new Student("Lynda", "Robison", 3.2)); cis162.addStudent(new Student("Sonya", "King", 3.9)); toDrop = "Stern"; beforeCount = cis162.countStudents(); cis162.dropStudent(toDrop); System.out.println("Course size: " + beforeCount + " students"); System.out.println("Course size after drop: " + cis162.countStudents() + " students"); } } import java.text.DecimalFormat; // Class representing a student public class Student { private String first; // first name private String last; // last name private double gpa; // grade point average // Student class constructor public Student(String f, String l, double g) {…