First code is top, second code is on bottom. This is for Java.
Q: In Java, Suppose x = 7.8. The value of the expression (int)(x + 0.5) is 8. True or False
A: The question has been answered in step2
Q: The following expression should equal 6.8, but in Java it does not. Why not? 0.2 + 1.2 + 2.2 + 3.2
A: GIVEN: The following expression should equal 6.8, but in Java it does not. Why not?0.2 + 1.2 + 2.2 +…
Q: Write a complete Java program to handle weather forecasts. The program should prompt the user for…
A: The answer is given below:-
Q: Question 1: Write a complete Java program - with your own code writing - that contains: 1. A main…
A: Solution: Java code: import java.util.Scanner; public class Main { /** * 5. A constant…
Q: va with screen shot for the code
A:
Q: In java write a program on online book store
A: Program Plan: Create a class Books with map that will store the name of the books along with…
Q: A simple plant -see the figure- can be constructed using simple Java instructions. a. Write a java…
A: The complete code is given below.
Q: Last month Joe purchased some stock in Acme Software, Inc. Here are the details of the purchase: •…
A: import java.util.*; public class Main{ public static void main(String[] args) { int…
Q: Based on the exercise we did in class, write a complete Java program that allows a user to play…
A: Given:
Q: basic java code, self-learner here so pls do use more // comments ya if needed pls label the…
A: The class Point has to be created with a toString() overloaded method. A second class named…
Q: java
A: Step 1: Explanations: this program this use to Oop concepts in java language. First creat a four…
Q: Ask the user for a number between 1 and 10. Output the Roman numerals version of that number. if the…
A: Given: Ask the user for a number between 1 and 10. Output the Roman numerals version of that number.…
Q: In Java, what is the final keyword? Give a specific example
A: To be determine: Define final keyword
Q: For the code in java below it shows a deck of 52 cards and asks the name of the two players and…
A: Given: For the code in java below it shows a deck of 52 cards and asks the name of the two players…
Q: A simple plant -see the figure- can be constructed using simple Java instructions. a. Write a java…
A: Since this is a multipart question i am able to answer onl part first of it
Q: You are responsible for writing the code necessary to perform a measurement unit conversions. In…
A: This problem can be solved using basic conversion formula like taking meters as input from user and…
Q: Problem: Ms. Cruz gives four exams during the semester in her Programming class. At the end of the…
A: Program: import java.util.*; public class Main { //method to calculate total public static…
Q: Write a structured Java program to calculate the parking fare for customers
A: Program Explanation: Import the text and util classes Define a class for implementing the parking…
Q: For the code in java below it shows a deck of 52 cards and asks the name of the two players and…
A:
Q: Create a method that randomly selects a letter in the alphabet. (in java)
A: The Answer is in Below Steps
Q: te a calculator in Java with a menu that loops back if the user wants to try again
A: I have given the java code for the calculator below.
Q: For the code in java below it shows a deck of 52 cards and asks the name of the two players and…
A: User Need: For the code in java below it shows a deck of 52 cards and asks the name of the two…
Q: Write a java program that asks the users to enter 2 numbers and the program computes the max value…
A: import java.util.Scanner;//to read inputpublic class Main{ /* Algorithm: step1:read two…
Q: d. A sentence consists of several words separated by a space. Given a sentence, you want to…
A: Note: This is a multiple-question-based problem. As per company guidelines, only the first question…
Q: For the code in java below it shows a deck of 52 cards and asks the name of the two players and…
A: Note: As you have not given the Player class description, that part of the code has been commented…
Q: Output the numbers 1-100, but make all numbers that are multiple of five Negative. Output a new line…
A: A number is divisible by 5 if its units place is 0 or 5.
Q: For the code in java below it shows a deck of 52 cards and asks the name of the two players and…
A: Given: Solution for Java program
Q: Java Questions - (Has 2 Parts). Based on each code, which answer out of the choices "A,B,C,D,E" is…
A: Here we are creating an object of Date class Date dt = new Date(); Then we are calling get time()…
Q: In Java, which data type stores the following text: "You are amazing."?
A: In Java, the datatype which stores the text "You are amazing." is String. Below is the given example…
Q: You were hired by PAGCOR as part of the programming team in-charge of automating its BINGO game.…
A: Lets see the solution.
Q: (Display three messages) Write a program that displays Welcome to Java,Learning Java Now, and…
A: Program code: //define class DisplayMessages class DisplayMessages { //define main method…
Q: Java code please 4. Jackpot! by CodeChum Admin Did you know that in lotteries, a 3-digit number with…
A: The program will be taking two inputs from the user and stored in number1 and number2 in integer…
Q: Please look at the images for the programming question. I am not sure sure where I should start on…
A: Few things to consider are: 1. variable balance must be available to all methods. Therefore, make…
Q: For this code in java, I'm stuck on an error im getting on line 21 and when the code works it should…
A: It will cause error as there is no variable named PlayerName .
Q: n Java, I want the user to enter in a 5-digit number, and if they enter incorrectly, I want to give…
A: import java.util.Scanner; public class Main{ public static void main(String[] args) { Scanner…
Q: JAVA LANGUAGE 3. The FizzBuzz Game by CodeChum Admin Let's play a game of FizzBuzz! It works just…
A: Algorithm: Start Read a number n If n%3==0 and n%5==0, print FizzBuzz Else if n%3==0, print Fizz…
Q: Write a complete Java program that displays all the numbers, from 1 to 200, that are divisible by…
A: To check the 200 numbers use loops and it is iterate for 1 to 200. Check the numbers one by one that…
Q: For the code in java below it shows a deck of 52 cards and asks the name of the two players and…
A: import java.util.ArrayList; import java.util.Scanner; import java.util.List; import…
Q: Please write a java code using the photo below. The second photo is the output of my program that I…
A: Check the code below.
Q: in a java program. Imagine that you own a flower store and you need to display a menu of all the…
A: I have implemented the given requirement as per the specification. The code is as follows: public…
Q: Primary U.S. interstate highways are numbered 1-99. Odd numbers (like the 5 or 95) go north/south,…
A: The, given information is: Primary U.S. interstate highways are numbered 1-99. Odd numbers (like the…
Q: Constantly ask the user for a number. End the program when zero is entered. Write a code in Java…
A: This can be done using an infinite while loop and can break when 0 is the input or we can make use…
Q: Write a code that generates a random lowercase letter. In java programm
A: Step by step explanation. Step of 1 of 3 Program plan: Create a class called LowerCaseLetter.…
Q: Write a code in Java that results like test 2&3
A: Given: Write a code in Java that results like test 2&3
Q: In Java, what will the following statement output? System.out.println("Hello " + 2 + 0 + 1 + 9…
A: let's see the output of the statemnet
Q: In Java: Primary U.S. interstate highways are numbered 1-99. Odd numbers (like the 5 or 95) go…
A: Code of this program is:
Q: In Java 1-make a program that prompt the user enter a shape name (Circle or Rectangle or line ) and…
A: The complete code is given below with output.
Q: For the code in java below it shows a deck of 52 cards and asks the name of the two players and…
A: Given: For the code in java below it shows a deck of 52 cards and asks the name of the two players…
First code is top, second code is on bottom. This is for Java.
What makes these two codes different?
(a) If x = 3, what will the first (code) print out?
(b) If x = 3, what will the second (code) print out?
(c)If x = 1, what will the first (code) print out?
(d) If x = 1, what will the second (code) print out?
Step by step
Solved in 8 steps with 4 images
- int getUpperScore(){ int upperScore = 0; for(int i = ONES; i <= SIXES; i++){ upperScore += score[i]; } return upperScore + getBonusScore(); } //Returns the score of the upper part of the board int getLowerScore(){ int lowerScore = 0; for(int i = THREE_OF_KIND; i <= YAHTZEE; i++){ lowerScore += score[i]; } return lowerScore; } //Returns the bonus points int getBonusScore(){ const int UPPER_SCORES_THRESHOLD = 63; const int BONUS_POINTS = 35; if(getUpperScore() >= UPPER_SCORES_THRESHOLD){ return BONUS_POINTS; } return 0; } //Returns the total score int getTotalScore(){ return getUpperScore() + getLowerScore(); } Test 10: Check upper board and having bonus correctly (0/3) failedIn C++ QUESTION 14 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; }; Write the function definition for the function perimeterpublic class Application { public static void main(String[] args) { Employee empl = new Employee(); empl.firstName = "Ali"; empl.lastName = "Omar"; empl.salary = 20000; Employee emp2 = new Employee(); emp2.firstName = "Mohamed"; emp2.lastName = "Nour"; emp2.salary = 30000; System.out.println("- System.out.printin("- empl.employeeSalary(); System.out.println("- empl.checkEmployeeSalary(emp1.salary, emp2.salary); System.out.printin("- System.out.println("- printEmployee(emp2); System.out.printin("- Employee employeeArr[] = new Employee[2]: employeeArr[0] = empl; employeeArr[1] = emp2; Application a = new Åpplication(); a.printArrayofEmployee(employeeArr); Non static (instance) start to call Static function to print ---------"); "); - Non Static function to print - --"); Non static (instance) start to call same class Static function to print --------); -"); Non Static function to print ----); System.out.println("- System.out.printin("- System.out.printin("Salary : " + Employee.salary);…
- // Some circle statistics public class DebugFour2 { publicstaticvoidmain(Stringargs[]) { double radius =12.6; System.out.println("Circle statistics"); double area = java.Math.PI * radius * radius; System.out.println("area is " + area); double diameter =2- radius; System.out.println("diameter is + diameter); } }26. Assume the declaration of Exercise 24. A. Write the statements that derive the class dummyClass from class base as a private inheritance. (2 lines are { and }.) "A1 is { "A2 is "A3 is )) B. Determine which members of class base are private, protected, and public in class dummyClass. "B1 is dummyClass is a deJava class Main { publicstaticvoid main(String[] args) { // Coin myPenny = new Coin(CoinType.PENNY); // Coin myNickel = new Coin(CoinType.NICKEL); // Coin myDime = new Coin(CoinType.DIME); // Coin myQuarter = new Coin(CoinType.QUARTER); // Coin myHalfDollar = new Coin(CoinType.HALF_DOLLAR); // Coin myDollar = new Coin(CoinType.DOLLAR); // System.out.println(printValue(myPenny)); // System.out.println(printValue(myNickel)); // System.out.println(printValue(myDime)); // System.out.println(printValue(myQuarter)); // System.out.println(printValue(myHalfDollar)); // System.out.println(printValue(myDollar)); } publicstatic String printValue(Coin c){ String result = ""; // result = String.format("The value of a %s is $%.2f", c.getName(), c.getValue()); return result; } }
- [java program] public class ScenarioAnalysis { // Instance variables privateVehicle[] vehicles; // all vehicless being analyzed privatedoublegasPrice; // price of one gallon of gas in dollars privatedoubleelectricityPrice; // price of 1 kWh in cents of a dollar, c$/kWh publicScenarioAnalysis ( doublegasPrice, doubleelectricityPrice ) { this.gasPrice = gasPrice; this.electricityPrice = electricityPrice; } /* * Updates the price of gas * Call computeCO2EmissionsAndCost() whenever there is an update on gas prices */ publicvoidsetGasPrice ( doublegasPrice ) { this.gasPrice = gasPrice; computeCO2EmissionsAndCost(); } /* * Returns the gas price */ publicdoublegetGasPrice () { returngasPrice; } /* * Updates the price of electricity * Call computeCO2EmissionsAndCost() whenever there is an update on electricity prices */ publicvoidsetElectricityPrice ( doubleelectricityPrice ) { this.electricityPrice = electricityPrice; } /* * Returns electricity price */ publicdoublegetElectricityPrice…public class LabProgram { public static void main(String args[]) { Course course = new Course(); String first; // first name String last; // last name double gpa; // grade point average first = "Henry"; last = "Cabot"; gpa = 3.5; course.addStudent(new Student(first, last, gpa)); // Add 1st student first = "Brenda"; last = "Stern"; gpa = 2.0; course.addStudent(new Student(first, last, gpa)); // Add 2nd student first = "Jane"; last = "Flynn"; gpa = 3.9; course.addStudent(new Student(first, last, gpa)); // Add 3rd student first = "Lynda"; last = "Robison"; gpa = 3.2; course.addStudent(new Student(first, last, gpa)); // Add 4th student course.printRoster(); } } // Class representing a student public class Student { private String first; // first name private String last; // last name private double gpa; // grade point average…class Point { private: int x, y ; public: : x(u), y(v) {} Point (int u, int v) int getX) { return x; } int getY () { return y; } void doubleVal() { *= 2: y *= 2; } }; int main () { const Point myPoint (5, 3) myPoint.doubleVal() ; cout << myPoint.getX() << " " return 0; << myPoint.getY() << "\n"; }
- /* TestCarSensor.java - program to test the CarSensor class.*/public class TestCarSensor{public static void main (String[] args){CarSensor generic = new CarSensor();CarSensor tempCel = new CarSensor("temperature sensor", -50, +300, "C"); CarSensor speed = new CarSensor("speed sensor", 0, 200, "km/h"); CarSensor speed2 = new CarSensor("speed sensor 2", 0, 200, "m/h"); // 2. test changing desc and limitsSystem.out.println ();System.out.println ( generic ); // display generic sensor (zero)generic.setDesc ("special sensor"); // change descriptiongeneric.setLimits (-5,5,"units"); // change limitsSystem.out.println ( generic ); // display generic sensor again// 3. test displaying object (calling .toString() )System.out.println ();System.out.println ( tempCel );System.out.println ( speed );System.out.println ( speed2 );// 4. test setlimits() ruleSystem.out.println ();System.out.println ( generic ); generic.setLimits (10, -10, "blah"); System.out.println ( generic ); generic.setLimits (-10,…C#Write the definition for the Triangle class that works for the following main() method.public static void Main(string[] args){Triangle tri1 = new Triangle(1.0,2.0);Triangle tri2 = new Triangle(1.0,2.0);Triangle tri3 = tri1 - tri2;tri3.DisplayDetails();if(tri1 == tri2){Console.WriteLine(“The area is: ” + tri3.CalculateArea());}else{Console.WriteLine(“Area cannot be calculated.”);}}Java Assignment Outcomes: Student will demonstrate the ability to utilize inheritance in a Java program. Student will demonstrate the ability to apply the IS A and HAS A relationships. Program Specifications: Start by watching Video Segment 16 from Dr. Colin Archibald's video series (found in the module overview). Key in the program shown in the video and make sure it works. Then, add the following: Animals have a Weight. Animals have a Height. Dog is an Animal. Dogs have a Name. Dogs have a Breed. Dogs have a DOB. Cat is an Animal Cats have a Name. Cats have 9 lives, so you need to keep track of the remaining lives once a cat dies. Bird is an Animal Birds have a wing span Birds have a canFly which is true or false (some birds cannot fly) Create a test class that creates one of each type of animal and displays the animal’s toString method. Submission Requirements: You must follow the rules from the prior assignments. UMLs and Design Tools are not required for this one. YOU MAY…