Movies always come with ratings. A bad movie may have 1.4 stars, and a great movie may have 4.9 stars. Your job is to write a program that gets a movie rating from the user as a double, and then rounds to the nearest int using the rounding with casting technique. For example, a run of your program may look like this: Please enter a movie rating: 3.4 Rating rounded: 3
Q: create a class that asks a user for 2 string inputs (USE The Java. Util. SCANNER) -compare…
A: write a Program in java on string operations given in problem statement
Q: What is the output produced by the following code? int *p1, *p2; p1 = new int; p2 = new int; *p1 =…
A: #include <iostream>using namespace std;int main(){ int *p1, *p2;p1 = new int;p2 = new…
Q: Use the compareTo method to write code that reads two names from the console and prints the one that…
A: The compareTo() method is used for string handling in which it compares two strings…
Q: Write a program that declares an int named year and set it equal to the current year. Then print it…
A: In this java program , we need to define the main function inside the public class Variables. Inside…
Q: Your job is to write a program that gets a movie rating from the user as a double, and then rounds…
A:
Q: Write a java program that helps the Lebanese scout to create an online tombola (lottery). Your…
A: import java.lang.Math;import java.util.Scanner;public class Main{ public static void main(String[]…
Q: public static int myMethod (int y, int z) { if (y > z) return y * z; else return myMethod (y - 2,…
A: In this problem, we need to give a condition when will the stack overflow condition will occur.…
Q: Exercise GradesStatistics (Method): Write a program called GradesStatistics, which reads in n grades…
A: Purpose of the program: This program asks the user to insert grades of multiple subjects into an…
Q: In this exercise you will write a program to compute the distance between any two geo locations. In…
A: we have given GeoLocation class we have to implement its main method which is given below
Q: Assume that you are not able to perform other operations on an int value thanto decrement it and…
A: Program code: //include required header files #include <iostream> using namespace std;…
Q: Write a program that inserts parentheses, a space, and a dash into a string of 10 user-entered…
A: Unless the user specify a breaking condition inside the while loop, it will iterate - Ask the user…
Q: A pentagonal number is defined as n(3n-1)/2 forn = 1 , 2 , …, and so on. Therefore, the first few…
A: Since, programming language is not mentioned in the question, we will answer this question in Java…
Q: Write an application that allows a user to enter any number of student quiz scores, as integers,…
A: Introduction of the Program: This C++ program takes score from the user and if scores are between…
Q: Write a program that calculates the revenue of a trip of a train composed of several train-cars. For…
A: #include<iostream> #include<string> #include<vector> using namespace std; class…
Q: What is the probability that in a classroom of x people, at least 2 will be born on the same day of…
A: Solution: Probability of having at least two people's birthdays on the same day through simulating…
Q: /** * You have a golden lottery ticket, with * ints a, b, and c on it. If the numbers are all…
A: public static int goldenTicket(int a, int b, int c) { if(a == b && b == c) return 20;…
Q: In computational geometry, often you needto find the rightmost lowest point in a set of points.…
A: A Java program is as follows, File name: “Sample.java” import java.util.Scanner; public class Sample…
Q: Write an application that prompts a user for two integers and displays every integer between them.…
A: Hey, you haven't mentioned the programming language. So, we are using java to solve this question.
Q: it is saying that they can not find symbol in quartsNeeded=input.NextInt(); final int…
A: Introduction of Program The above program is written in Java Programming language and Java is Case…
Q: Write a program that moves a forester unit and a desert corps unit to a given target location and…
A: Answer : #include <iostream> #include <math.h> #include <string.h> using namespace…
Q: create a class that asks a user for 2 string inputs (USE The Java. Util. SCANNER) -compare the…
A: (Disclaimer: Since you have asked multiple questions, we will solve the first question for you. If…
Q: Write a program in a class contructor and destructor to print two numbers and then find ? the…
A: Note: Here you didn't mention any programming language so we are writing the program in the C++…
Q: Lab Work 2 In this lab work, you will implement a coffee shop example. In this coffee shop,…
A: To create: To write a menu-driven C program for a coffee shop that asks the user the number of…
Q: I don't know how to do this. Thanks in advance. Modify the CountByFives application from Chapter 6…
A: Algorithm: Start Read the countby value i.e start Initialize stop to 500 Initialize count to 0…
Q: 1 public static int foo(int a, int b) { if (a < b) 2 3 return 0; 4 else return 1 + foo(a-b, b); 6 }
A: The above code divides a by b using the recursive procedure and returns the quotient. This can be…
Q: You have a red lottery ticket showing ints a, b, and c, each of which is 0, 2. If they are all the…
A: Given:
Q: Write a method that returns anumber, given an uppercase letter, as follows:public static int…
A: The user is prompted to enter a number. The enter number is stored in a string, s1. The string is…
Q: Write a program that reads a student’s name together with his or her test scores. The program should…
A: Grading System: 90-100, A; 80-89, B; 70-79, C; 60-69, D; 0-59, F student.txt file Johnson 85 83 77…
Q: Write a method that prints numbers using the following header:public static void printNumbers(int…
A: Write a test program to prints the numbers between num1 and num2 with the specified numbers per line…
Q: You can use the following logic to determine whether a number is even or odd: if ((number % 2) == 0)…
A: Answer in step2
Q: Write an application that counts by five from 5 through 500 inclusive, and that starts a new line…
A: Program Approach: Defining a class as public within which the function main is defined. In the main…
Q: 1. Write down a method that will take an integer as a parameter and will return 1 if the integer is…
A: Program description: n is the user input integer variable that is used to store the upper limit of…
Q: What is the value of x when i = 4? #include int main (void) { int x = 0; for (int i = 0; i <= 4;…
A: Looping statement: Loop is repeating a set of statements inside the block of statements until a…
Q: // Return the reversal of an integer public static int reverse(int number) // Return true if number…
A: Hi. Let's move on to the code in the next step. I have included comments in the code that will…
Q: 1 public static int foo(int a, int b) { if (a < b) 2 return 0; else return 1 + foo(a-b, b); 6.
A: BASE CASE:In a recursive algorithm, the base case is the case that is not recursive.…
Q: public static int test(int v{ for(int i= 0; i <a.length; i+ +) if(a[i] = = v) return v; } return -…
A: Answer in step2
Q: public static int bar (int number) { while (number > -3) { if (number > 5) { System.out.print…
A: Here in the function foo(), the value of the number is 9. Now in the function, it prints the SE115…
Q: Write a program that asks the user to enter three numbers. Then passes these numbers to the…
A: Program:- #include <iostream>using namespace std;int largest(int a,int b,int c){ if(a>b…
Q: Write the output of the following code: mister_pet = Pet("Master", "Dog") mister_dog =…
A: According to the information given:- We have to find out the output of the mentioned code. In order…
Q: Write a program GuessMyNumber game. When it's finished, it will work like this I'm thinking of a…
A: The complete code is given below . Please like , thank you ?
Q: Modify the program you wrote in exercise 3.32 so that it prints a hollow square. For example, if…
A: Program: /*header file*/ #include<stdio.h> /*program begins with the function main*/ int main…
Q: public static int foo(int a, int b) { if (a < b) return 0; else return 1 + foo(a-b, b);
A: The value returned for foo(4, 2) is 2. The value returned for foo(5, 3) is 1.
Q: THIS IS MEANT TO BE IN JAVA So far we've learned variables, branches, loops, and some array. The…
A: calculation for gas cost:- dollars_gallon*distance1/miles_gallon take the values for car's…
Q: public static int test(int n, int k) { if (k == 0 || k == n) { return 1; } else if (k>n) { return 0;…
A: The implementation that corresponds to recursion is this. The outcome will be 1 if indeed the value…
Q: A pentagonal number is defined as n(3n-1)/2 for n = 1, 2, …, and so on. Therefore, the first few…
A:
Q: Write a method with the following header that returns a pentagonal number: public static int…
A: The nth pentagonal number pn is given by the formula: pn = (3n2 - n) / 2 for n >= 1.
Q: What is the value of maxNumber after the code that follows is executed?int number = 0;int maxNumber…
A: The program is a Java program which uses function random to generate random numbers between 0 and 1.…
Q: write a program that prints the value of sizeof (int), sizeof (short), sizeof (long),…
A: Program to print the sizeof integer type, short type, long type, float type, double type and long…
Q: So I have what I think the code would be but it doesn't like it. This is the question- Write a…
A: Hey, thank you very much for your question. As per your question, the information is gathered as…
Q: In this exercise you will write a program to compute the distance between any two geo locations. In…
A: Given that, write a program to compute the distance between any two geo-locations. In this program,…
use java
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 4 images
- public class Driver { /** * @param args */ static Scanner keyboard = new Scanner(System.in); publicstaticvoid main(String[] args) { Mailbox[] mailboxes = new Mailbox[5]; Mailbox mailbox1 = new Mailbox("gmail"); Mailbox mailbox2 = new Mailbox("outlook"); Mailbox mailbox3 = new Mailbox("icloud"); mailboxes[0] = mailbox1; mailboxes[1] = mailbox2; mailboxes[2] = mailbox3; Email email1 = new Email(); email1.setDate(new Date(2022, 11, 5)); email1.setSubject("Exam2 guidelines "); Email email2 = new Email(new Date(2021, 3, 5), true, "Quiz3 in Ch7"); Email email3 = new Email(); email3.setDate(new Date(2020, 11, 3)); email3.setSubject("Late submission policy"); mailbox2.addEmail(email1); mailbox2.addEmail(email2); mailbox2.addEmail(email3); // System.out.println("Hello! What would you like to do "); intselection = displayMenu(); while (selection != 5) { // selection = displayMenu(); switch (selection) { case 1: System.out.print("Enter the client: "); String…public class StairViewer public static void main(String(] args) // Step 2: Create a rectangle and draw it as the // top step of the stair // location: (20, 10) // size: (20, 20) 18 // Step 3: Create a rectangle and draw it as the 19 // middle step of the stair 20 // location: below the top step, aligned on left // size: (40, 20) 21 22 23 24 // Step 4: Create a rectangle and draw it as the 25 // bottom step of the stair 26 // location: below the middle step, aligned on left // size: (60, 20) 27 28 29 30 } 31 32PLEASE TYPE ONLY*** JAVA PROGRAMMING Program #2: Write a class called YourFirstNameLine that represents a line segment between two Points. Your Line objects should have the following methods: public YourFirstNameLine (Point p1, Point P2): construct a new Line that contains the given two Points public Point getStartPoint(): return this Line’s first endpoint public Point getEndPoint(): return this Line’s second endpoint public String toString(): return a String representation of this Line, such as “[(2,3), (4,7)]” public double getSlope(): return the slope of this Line. The slope of a line between points (x1, y1) and (x2, y2) is equal to (y2-y1)/(x2-x1). If x2 equals x1, the denominator is zero and the slope is undefined, so you may return a zero in this case public void draw (Graphics g): draw a line in a DrawingPanel. Write a client class called YourFirstNameLineTest with main method to test your Line class. In the main method, you need create a line object with the last four…
- public class TwoColors 10 { public static void main(String[] args) { Scanner in = new Scanner(System.in); 11 12 13 14 System.out.print("Enter your first favorite color: "); 15 16 // Step 2: Read in the next line of input and assign • it to a String variable color1 17 // 18 19 // Step 3: Trim spaces from both end and convert the // // 20 input to all lowercase and assign it back 21 22 to the same variable 23 24 System.out.print("Enter your second favorite color: "); 25 26 // Step 4: Read in the next line of input and assign 27 // it to a String variable color2 28 29 30 // Step 5: Trim spaces from both end and convert the // // 31 input to all lowercase and assign it back 32 33 to the same variable 34 35 // Step 6: Display a message according to the following: // 36 first color 37 second color message light blue 38 red That's wonderful! light blue 39 red That's even better! That's also great! 40 otherwise 41 42class Param3 { public int x; private void increase(int p) { x = x*p; } public void calculateX(int y) { increase(y); } public int getX() { return x; } } // in another class Param3 q3 = new Param3(); q3.x = 5; q3.calculateX(7); System.out.println(q3.getX()); what would be the answer for the last two lines ? also above were x = x*p do both x in here are the fields? wouldn't that be cnofusing?mport java.util.Scanner; public class ParkingCharges { // function to calculate the basic charge using the asked hours static double getBasicCharge(int hours) { if (hours >= 7 && hours <= 8) return 5.50; else if (hours >= 5 && hours <= 6) return 4.50; else if (hours >= 2 && hours <= 4) return 4.00; return 3.00; } // function to return the amount to subtract based on local living and OAP static double getDiscount(String isLocal, String isOAP) { if (isOAP.equals("Yes") && isLocal.equals("Yes")) return 2.0 + 1.0; else if (isOAP.equals("Yes")) return 2.0; else if (isLocal.equals("Yes")) return 1.0; return 0; } public static void main(String[] args) { // create a new Scanner object Scanner sc = new Scanner(System.in); // prompt the user to ask if they are disabled…
- 1 class rectangle { 2. private: double width; 3. 4. double length; 5. public: 6. rectangle(double w=0.0, double l=0.0) 7. { width=w; length=w; } void operator++() //prefix ++ operator 10. {++width; +length; } 11. void operator++() //postfix ++ operator 12. {width++; length++; } 13. }; 9. Which line of the above C++ code contains an error? Select one: а.11 b.9 c.No errors d.6Computer Science i need help with a lego mindstorm code nxt v1 code import lejos.nxt.*; import lejos.robotics.navigation.*; /** * Robot that stops if escape button pressed. */ public class TravelTest { DifferentialPilot pilot; public void go() { pilot.travel(100, true); //100 centimeters pilot.rotate(90.0); //degrees while (pilot.isMoving()) { if (Button.ESCAPE.isPressed()) pilot.stop(); } System.out.println(" " + pilot.getMovement().getAngleTurned()); System.out.println(" " + pilot.getMovement().getDistanceTraveled ()); Button.waitForPress(); } public static void main(String[] args) { TravelTest traveler = new TravelTest(); traveler.pilot = new DifferentialPilot(3.1, 13.5, Motor.A, Motor.C); //parameters in centimeters traveler.go(); 63 } } In the above example, we cause the robot to rotate in place by a specified angle by using • void rotate(double degrees) Moreover, we must have accurate values for wheelDiameter and trackWidth for this method to produce accurate results. The…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; }; Set the length of the rectangle to 24 and the width to 30.
- 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.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.Look at the following applet code snippet: 1 import javax.swing.*; 2 import java.awt.*; 3 public class GraphicsTest extends JApplet 4 { 5 public void init() 6 { 7 getContentPane().setBackground(Color.WHITE); 8 } 9 public void paint(Graphics g) 10 { 11 int[] xCoords = {20, 20, 60, 100, 140, 140, 100, 60}; 12 int[] ycoords = {20, 100, 140, 140, 100, 60, 20, 20}; 13 super.paint(g); 14 g.setColor(Color.YELLOW); 15 g.fillPolygon(xCoords, yCoords, 8); 16 g.setColor(color.BLACK); 17 g.setFont(new Font("SansSerif", Font.BOLD, 35)); 18 g.drawString("SLOW", 35, 95); 19 } 20 } How many vertices does the polygon have? Justify your answer.