Question

In: Computer Science

1/Your team was asked to program a self-driving car that reaches its destination with minimum travel...

1/Your team was asked to program a self-driving car that reaches its destination with minimum travel time.

Write an algorithm for this car to choose from two possible road trips. You will calculate the travel time of each trip based on the car current speed and the distance to the target destination. Assume that both distances and car speed are given.

2/

Write a complete Java program that do the following:

  1. Declare String object and a variable to store your name and ID.
  2. DisplayYour Name and Student ID.
  3. Display Course Name, Code and CRN
  4. Replace your first name with your mother/father name.
  5. Display it in an uppercase letter.

Note:Your program output should look as shown below.

My Name: Ameera Asiri

My student ID: 123456789

My Course Name: Computer Programming

My Course Code: CS140

My Course CRN: 12345

AIYSHA ASIRI

Note: Include the screenshot of the program output as a part of your answer.

3/

Write a tester program to test the mobile class defined below.

Create the class named with your id (for example: Id12345678) with the main method.

  1. Create two mobiles M1 and M2 using the first constructor.
  2. Print the characteristics of M1 and M2.
  3. Create one mobile M3 using the second constructor.
  4. Change the id and brand of the mobile M3. Print the id of M3.

Your answer should include a screenshot of the output. Otherwise, you will be marked zero for this question.

public class Mobile {

private int id;

private String brand;

public Mobile() {

    id = 0;

    brand = "";

}

public Mobile(int n, String name) {

    id = n;

    brand = name;

}

public void setBrand(String w) {

    brand = w;

}

public void setId(int w) {

    id = w;

}

Public int getId() {

return id;

}

public String getBrand() {

return brand;

}

}

4/

Write a method named raiseSalary that accepts two integers as an argument and return its sum multiplied by 15%. Write a tester program to test the method. The class name should be your ID (for example: Id12345678).

Your answer should include a screenshot of the output. Otherwise, you will be marked zero for this question.

Solutions

Expert Solution

//Q1:

import java.util.*;
public class selfDrivingCar {
public static void main(String[] args) {
int distance1,distance2,speed1, speed2;
Scanner sc = new Scanner(System.in);
System.out.println("Please enter first trip details distance and car speed: ");
distance1 = sc.nextInt();
speed1 = sc.nextInt();
double time1 = distance1/speed1;
System.out.println("Please enter second trip details distance and car speed: ");
distance2 = sc.nextInt();
speed2 = sc.nextInt();
double time2 = distance2/speed2;
if(time1 < time2) {
System.out.println("Choose first trip as time taken is less than second trip ");
}
else if(time2 < time1) {
System.out.println("Choose second trip as time taken is less than first trip");
}
else {
System.out.println("Choose either trip as time taken is equal in both trips");
}
}
}

//Q2:

import java.util.*;
public class StudentDetails {
public static void main(String[] args) {
String name;
int id;
String courseName;
String code;
int CRN;
Scanner sc = new Scanner(System.in);
System.out.println("Enter your name");
  
name = sc.nextLine();
System.out.println("Enter your student ID");
id = sc.nextInt();
System.out.println("Enter Course Name");
sc.nextLine();
courseName = sc.nextLine();
System.out.println("Enter your course Code");
code = sc.next();
System.out.println("Enter your course CRN");
CRN = sc.nextInt();
System.out.println("Enter your mother/father name");
sc.nextLine();
String mother = sc.nextLine();
System.out.println("My Name: "+name);
System.out.println("My student ID: "+id);
System.out.println("My Course Name: "+courseName);
System.out.println("My Course Code: "+code);
System.out.println( "My Course CRN: "+CRN);
String[] arr = name.split(" ");// to get your first name
mother = mother.split(" ")[0];
System.out.println(mother.toUpperCase()+" "+arr[1].toUpperCase());
}
}

//Q3:

import java.util.*;
public class myid {

public static void main(String[] args) {
// TODO Auto-generated method stub
Mobile M1, M2;
M1 = new Mobile();
M2 = new Mobile();
System.out.println("Characteristics of M1: ");
System.out.println("id: "+M1.getId());
System.out.println("Brand: "+M1.getBrand());
  
System.out.println("Characteristics of M2: ");
System.out.println("id: "+M2.getId());
System.out.println("Brand: "+M2.getBrand());
  
Mobile M3 = new Mobile(2,"Micromax");
  
//Change the id and brand of the mobile M3.
M3.setId(5);
M3.setBrand("Motorola");
System.out.println("Characteristics of M3: ");
System.out.println("id: "+M3.getId());
System.out.println("Brand: "+M3.getBrand());
}

}

//Q4:

import java.util.*;
public class YourID {

public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner sc = new Scanner(System.in);
int first,second;
System.out.println("Enter two integers");
first = sc.nextInt();
second = sc.nextInt();
  
System.out.println(raiseSalary(first, second));
}
static double raiseSalary(int a, int b) {
return (a+b)*1.15;
}

}


Related Solutions

Your team was asked to program a self-driving car that reaches its destination with minimum travel...
Your team was asked to program a self-driving car that reaches its destination with minimum travel time. Write an algorithm for this car to choose from two possible road trips. You will calculate the travel time of each trip based on the car current speed and the distance to the target destination. Assume that both distances and car speed are given.
1/Your team was asked to program a self-driving car that reaches its destination with minimum travel...
1/Your team was asked to program a self-driving car that reaches its destination with minimum travel time. Write an algorithm for this car to choose from two possible road trips. You will calculate the travel time of each trip based on the car current speed and the distance to the target destination. Assume that both distances and car speed are given. 2/ Write a complete Java program that do the following: Declare String object and a variable to store your...
MARKETING! Google is developing a self-driving car that will be in the marketplace in the near...
MARKETING! Google is developing a self-driving car that will be in the marketplace in the near future. Identify a potential market segment and describe the value proposition that would meet the needs of this target customer group. What need is being fulfilled? What benefits are being sought?
With regard to the self-driving car, and the research conducted by the Moral Machine project; provide...
With regard to the self-driving car, and the research conducted by the Moral Machine project; provide your own ranking for the following (1= most important to save; 9= least important to save).                                                                                         # Ranking Category Sparing the young Sparing the fit Inaction (doing nothing) Sparing the most (#) people Sparing the lawful Sparing humans over animals Sparing pedestrians Sparing women Sparing people of higher social status Which group did you prioritize as most important? Which group was the...
If you needed to compare two simulated scenarios, and in one of them a self-driving car...
If you needed to compare two simulated scenarios, and in one of them a self-driving car is braking up to -3 meters per second squared, in another up to -8 meters per second squared (unit of acceleration), which one do you think is more risky? Please explain your answer or how you arrived to this conclusion.
1. A travel agency would like to track the destination of each flight. Given the following...
1. A travel agency would like to track the destination of each flight. Given the following business rule, what constraint(s) can you apply to the flight table, given there is also a destination table? "A flight must be associated with a destination". Question 1 options: Referential integrity Check constraint Nullability Default constraint 2. Constraint applied to a one-to-many relationship when a referenced record (on the 1 side) is deleted, then the referencing records (on the Many side) should also be...
You are in your car A on the 407 driving at a constant velocity ~vA =...
You are in your car A on the 407 driving at a constant velocity ~vA = (vA, 0, 0) and next to it another car (B) takes the exit ramp on one of Toronto’s huge exchangers to get onto the 404. For consistency we set the two cars to start at (0, 0, 0) at t = 0 and car B turns in the positive y direction. The exchanger can be seen as a quarter circle of radius R. 1....
1. GLS Chapter 7, Question 13: True or false: Average variable cost reaches its minimum point...
1. GLS Chapter 7, Question 13: True or false: Average variable cost reaches its minimum point at a lower level of output than average total costs. Explain your answer, using a graph of average and marginal costs to illustrate.
What are some important ethical concerns with self-driving cars? a minimum two page double spaced response...
What are some important ethical concerns with self-driving cars? a minimum two page double spaced response is required please
Your team will make a modification of the program #1 above, that will read in the...
Your team will make a modification of the program #1 above, that will read in the string as a “command-line argument” to your program, instead ofhaving the user type it while your program is running. Your program should print out the inverted string to the screen. For example, if you are running your program in the command window (by clicking the Start button, then typing in “cmd”, then pressing Enter, then using the “cd ” command to change to the...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT