1 import java.util.Scanner; 2 3 public class Carrots { 4 public static void main(String[] args) { 5 Scanner scnr = new Scanner(System.in); 6 int numCarrots; // Creates an integer variable named numCarrots 7 8 /* Your code goes here */ 9 10 11 } }
Q: 1. Place all the Menus in separate Methods. 2. Place computations in separate Methods and call the…
A: In cases where the question has multiple questions, we are needed to solve only one. We have here…
Q: InheritanceDemo.java: // StudentName Today's Date public class InheritanceDemo { public…
A: Actually, given information: InheritanceDemo.java: // StudentName Today's Date public class…
Q: ssion that will cause the following code to print "Equal" if the value of sensorReading is "close…
A: In the below code, approximate value is compared with rounding using Math.round() function . It will…
Q: public class ReversedDigit { public static void main(String[] args) { Scanner scan =…
A: The do-while loop is a variant of the while loop.
Q: Java Constructor(String) This constructor will take a string of digits(no commas) and turn it into…
A: Actually, the answer has given below:
Q: import java.util.Scanner; 2 public class BMICalculation { Y 1 23456 3- 7 68 9 10 11 12 13 } public…
A: The class BMI that you defined may be to blame for the problem. It would be preferable if you had…
Q: his is my code but it does not match the sample code please help
A: I have provided JAVA CODE along with CODE SCREENSHOT and OUTPUT SCREENSHOT----------------
Q: import java.util.Scanner; public class Application { public static void main(String[] args) { int…
A: Give a Java program All the errors are discussed below.
Q: import java.util.Scanner; public class WinningTeam { public static void main(String[] args) {…
A: Class Definition:Define a class named Team.Declare private instance variables: name (String), wins…
Q: import java.util.Scanner; public class MileConversionsInteractive { public static void…
A: The answer to the following question is :
Q: import java.util.Arrays; import java.util.Scanner; public class Game { private Player[]…
A: In Java, an exception which refers to the one it is an event that occurs when an error condition is…
Q: Write a pesudocode for the following code: public class EOM1 { public static void main(String[]…
A: The above java code is indicating a transaction between customer and the salesman. The customer buys…
Q: /** Cleans a phone number. @param phoneNumber a phone number that should contain ten digits and…
A: The only error in your programme was related to the substring method. Java String class contains a…
Q: class Excep { public static void main(String[] args){ try{ int arr[]=(1,2}; int x = arr[1]/arr[0]-1;…
A: Define class Excep. Define main function. Define try block. Define array arr with values 1 and 2.…
Q: public class NumbersDemo { public static void displayTwiceTheNumber(int number){…
A: Below is the complete solution with explanation in detail for the given question in Java Programming…
Q: Define a method find Lot() that takes two integer parameters as the hourly parking price and the…
A: We need to create a java program Define a method findLot() that takes two integer parameters as the…
Q: using System; class Program { publicstaticvoid Main(string[] args) { int number = 1,i; while…
A: Required: how can this program be fixed to choose three random numbers in C# between 1-88…
Q: public class Con{ public static void main(String[] args) { int[] ar=(2,5,7,9}; int i-2; final int…
A: Ouput of the java code public class Con{public static void main(String[] args){int[]…
Q: import java.util.Scanner; public class InstrumentInformation { public static void main(String[]…
A: Main Algorithm:Start.To read user input, create a Scanner object with the name scnr.Create an…
Q: symbol: variable circleArea location: class Geometry Geometry.java:114: error: cannot find symbol…
A: Below is the code :-
Q: import java.util.Scanner; public class WinningTeam { public static void main(String[] args) {…
A: Dear student in Team.java class set methods were not correct. Now corrected and program is working…
Q: Java Questions - (Has 2 Parts). Based on each code, which answer out of the choices "A, B, C, D, E"…
A: Solution:
Q: The Student Painters company paints dorm rooms. The rooms have one window and one door. The room is…
A: For the given problem, below is the Java code.
Q: Input Your output starts with Expected output starts with 17 10 Credits: 94 Dice total: 94 Dice…
A: Given the code, please go through the comments in the corrected code, stated as "UPDATE". This will…
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: Write an if-else statement for the following: If userTickets is less than 6, execute award Points =…
A: Your given program is logically correct but the issue is in the closing of blocks. Blocks were…
Q: import java.util.Scanner; public class Relational { public static void main(String [ args) { int…
A: Given To complete the java program. import java.util.Scanner; public class EqualityAndRelational…
Q: Please correct the error for this code: import java.util.Scanner; // import Scanner class required…
A: import java.util.Scanner; // import Scanner class required to accept input from userclass Employee{…
Q: 4:Compare output Output differs. See highlights below. Input Your output starts with Expected output…
A: Given the code, please go through the comments in the corrected code, stated as "UPDATE". This will…
Q: Fix the code Make it look like the expect
A: After fixing the code , I have provided JAVA CODE along with CODE SCREENSHOT and also…
Q: // JumpinJive.java - This program looks up and prints the names and prices of coffee orders. //…
A: Use a loop to iterate and search and updated foundIt if requested addOn found in array
Q: import java.util.Scanner; public class MealEstablishmentDirectory { public static void main…
A: Java class named MealEstablishment with three methods: setRating, setState, and print. These methods…
Q: Not all tests passed. X 1: Compare output ^ Output differs. See highlights below. Input 100 Annual…
A: I modified the code and provide the code with the correct output and code screenshot and code…
Q: Fix all the errors and send the code please // Application looks up home price // for different…
A: After removing error, the resulting Java codes are: import java.util.*;public class DebugEight3{…
Q: Question 2. package sortsearchassigncodeex1; import java.util.Scanner; import java.io.*; // //…
A: Function fillArray() takes Scanner class object and an array as function parameter. The function…
Q: Please create a flowchart for the following program: // Import Scanner class import…
A: The flow chart for the given program is as follows.
Q: import java.util.Scanner; public class TriangleArea { public static void main(String[] args) {…
A: After completing the code, I have provided JAVA CODE along with CODE SCREENSHOT and OUTPUT…
Q: Make a game. package p1; public class Game { public static void main(String[] args) {…
A: The code you provided is a basic skeleton for a game implemented in Java. Here's a breakdown of the…
Q: Write a program that takes in three integers as inputs and outputs the largest value. Use a try…
A: The provided program aims to read up to three integer inputs from the user and output the largest of…
Q: import java.util.Scanner; public class TriangleArea { public static void main(String[] args) {…
A: I have provided JAVA CODE along with OUTPUT SCREENSHOT-----------
Q: import java.util.Scanner; public class leapYearLab { public static void main(String[] args) {…
A: Please consider the modified implementation below, I have implemented in a very easy way. So that…
Q: import java.util.Scanner; public class CharMatch { public static void main(String[] args) {…
A: Introduction : Explanation : This program is designed to check if a character in a given string…
Q: Fix the errors and send the code please // Application allows user to enter a series of words // and…
A: The code has been reviewed and modified to remove all errors.
Q: public class Course{String name;String dept;int number;public Course (String n, String d, int…
A: To accomplish the task as described, you need to make a few changes and additions to your Course…
Q: public class Test { } public static void main(String[] args) { int a = 10;…
A: The output of the above code will be
Step by step
Solved in 3 steps with 1 images
- public class Test { } public static void main(String[] args) { String str = "Salom"; System.out.println(str.indexOf('t)); }StringFun.java import java.util.Scanner; // Needed for the Scanner class 2 3 /** Add a class comment and @tags 4 5 */ 6 7 public class StringFun { /** * @param args not used 8 9 10 11 12 public static void main(String[] args) { Scanner in = new Scanner(System.in); System.out.print("Please enter your first name: "); 13 14 15 16 17 18 System.out.print("Please enter your last name: "); 19 20 21 //Output the welcome message with name 22 23 24 //Output the length of the name 25 26 27 //Output the username 28 29 30 //Output the initials 31 32 33 //Find and output the first name with switched characters 34 //All Done! } } 35 36 37// This class discounts prices by 10% public class DebugFour4 { public static void main(String args[]) { final double DISCOUNT_RATE = 0.90; int price = 100; double price2 = 100.00; tenPercentOff(price DISCOUNT_RATE); tenPercentOff(price2 DISCOUNT_RATE); } public static void tenPercentOff(int p, final double DISCOUNT_RATE) { double newPrice = p * DISCOUNT_RATE; System.out.println("Ten percent off " + p); System.out.println(" New price is " + newPrice); } public static void tenPercentOff(double p, final double DISCOUNT_RATE) { double newPrice = p * DISCOUNT_RATE; System.out.println"Ten percent off " + p); System.out.println(" New price is " + newprice); } }
- import java.util.Scanner;public class MP2{public static void main (String[] args){//initialization and declarationScanner input = new Scanner (System.in);String message;int Option1;int Option2;int Quantity;int TotalBill;int Cash;int Change;final int SPECIALS = 1;final int BREAKFAST = 2;final int LUNCH = 3;final int SANDWICHES = 4;final int DRINKS = 5;final int DESSERTS = 6;//For the Special, Breakfast, Lunch Optionsfinal int Meals1 = 11;final int Meals2 = 12;final int Meals3 = 13;final int Meals4 = 14;//First menu and First OptionSystem.out.println("\t Welcome to My Kitchen ");System.out.println("\t\t SPECIALS");System.out.println("\t\t [2] BREAKFAST MEALS");System.out.println("\t\t [3] LUNCH MEALS");System.out.println("\t\t [4] SANDWICHES");System.out.println("\t\t [5] DRINKS");System.out.println("\t\t [6] DESSERTS");System.out.println("\t\t [0] EXIT");System.out.print("Choose an option ");Option1 = input.nextInt();//first switch case statementsswitch(Option1){case (SPECIALS):message…8) Now use the Rectangle class to complete the following tasks: - Create another object of the Rectangle class named box2 with a width of 100 and height of 50. Note that we are not specifying the x and y position for this Rectangle object. Hint: look at the different constructors) Display the properties of box2 (same as step 7 above). - Call the proper method to move box1 to a new location with x of 20, and y of 20. Call the proper method to change box2's dimension to have a width of 50 and a height of 30. Display the properties of box1 and box2. - Call the proper method to find the smallest intersection of box1 and box2 and store it in reference variable box3. - Calculate and display the area of box3. Hint: call proper methods to get the values of width and height of box3 before calculating the area. Display the properties of box3. 9) Sample output of the program is as follow: Output - 1213 Module2 (run) x run: box1: java.awt. Rectangle [x=10, y=10,width=40,height=30] box2: java.awt.…Integer userValue is read from input. Assume userValue is greater than 1000 and less than 99999. Assign tensDigit with userValue's tens place value. Ex: If the input is 15876, then the output is: The value in the tens place is: 7 2 3 public class ValueFinder { 4 5 6 7 8 9 10 11 12 13 GHE 14 15 16} public static void main(String[] args) { new Scanner(System.in); } Scanner scnr int userValue; int tensDigit; int tempVal; userValue = scnr.nextInt(); Your code goes here */ 11 System.out.println("The value in the tens place is: + tensDigit);
- main Application public class Application { public static void main(String[] args) {//Create library objectLibrary l = new Library();//Add booksl.add(new Kids("KidsBook1", "author1", 18, 5));l.add(new Kids("KidsBook2", "author2", 15, 7));l.add(new Kids("KidsBook3", "author3", 10, 9));l.add(new Scientific("ScientificBook1", "author1", 12));l.add(new Scientific("ScientificBook2", "author2", 13));//Borrower objectsBorrower b1 = new Borrower("Borrower1", 1, 10, 2);Borrower b2 = new Borrower("Borrower2", 2, 6, 5);//Borrower1 borrow 2 booksif (b1.getMaxBookNum() <= b1.getSerialNumbers().size()) {System.out.println("Reached maximum borrowings!!!");} else {if (l.borrow(18, b1)) {b1.borrow(18);}}if (b1.getMaxBookNum() <= b1.getSerialNumbers().size()) {System.out.println("Reached maximum borrowings!!!");} else {if (l.borrow(15, b1)) {b1.borrow(15);}}//Borrower2 borrow 1 bookif (b2.getMaxBookNum() <= b2.getSerialNumbers().size()) {System.out.println("Reached maximum borrowings!!!");}…InheritanceDemo.java: // StudentName Today's Date public class InheritanceDemo { public static void main(String[] args) { KleenexBox kb1 = new KleenexBox(); KleenexBox kb2 = new KleenexBox(100); Box justABox = new Box(); System.out.println("justABox has area " + BoxArea(justABox)); System.out.println("kb1 has area " + BoxArea(kb1)); System.out.println("kb2 has this many square inches of tissue: " + KleenexArea(kb2)); } public static double BoxArea (Box b) { return b.width * b.length; } public static double KleenexArea (KleenexBox a) { return a.width * a.length * a.numTissues; } } Box.java: // Student Name Today's Date public class Box { public double width; public double length; public String label; } KleenexBox.java: // Student's Name Today's Date public class KleenexBox extends Box { public int numTissues; // A new Kleenex box public KleenexBox() { numTissues = 50; length = 8.0; width = 5.0; } // A new Kleenex box with a specific number of tissues public…I have this code: import java.util.Scanner; public class CalcTax { public static void main(String[] args) { Scanner sc = new Scanner(System.in); // Welcome message System.out.println("Welcome to my tax calculation program."); // Declare the variables int i, pinCode, maxRetries = 3; String choice; // Get the PIN code for (i = 0; i < maxRetries; i++) { System.out.print("Please enter the PIN code: "); pinCode = sc.nextInt(); if (pinCode == 5678) { break; } System.out.println("Invalid pin code. Please try again."); } if (i == maxRetries) { System.out.println("Invalid pin code. You have reached the maximum number of retries."); System.exit(0); } // Get the income, interest, deduction, and paid tax amount double income, interest, deduction, paidTax; do { System.out.print("Please…
- Please help me fix the code Make it looks like the expected import java.util.Scanner; public class NumberLoops { public static void main(String[] args) { double num; double result = 1; int i; Scanner sc = new Scanner(System.in); // Create a Scanner object // Take user input for the Positive Number System.out.print("Enter a positive integer: "); num = sc.nextDouble(); // Read user input // if the input number is not an integer if(num % 1 != 0) { // print the message System.out.println("Not an Integer: " + num); System.exit(0); } // if the number is not a positive number if(numI need this debugged. Thanks in advance. // Application looks up home price// for different floor plans// allows upper or lowercase data entryimport java.util.*;public class DebugEight3{public static void main(String[] args){Scanner input = new Scanner(System.in);String entry;char[] floorPlans = {'A','B','C','a','b','c'};int[] pricesInThousands = {145, 190, 235};char plan;int x, fp = 99;String prompt = "Please select a floor plan\n" +"Our floorPlanss are:\n" + "A - Augusta, a ranch\n" +"B - Brittany, a split level\n" +"C - Colonial, a two-story\n" +"Enter floorPlans letter";System.out.println(prompt);entry = input.next();plan = entry.charAt(1);for(x = 0; x < floorPlans.length; ++x)if(plan == floorPlans[x])x = fp;if(fp == 99)System.out.println("Invalid floor plan code entered");else{if(fp >= 3)fp = fp - 3;System.out.println("Model " +plan + " is priced at only $" +pricesInThousands[fp] + ",000");}}}