Questions
JAVA PROGRAMMING Part 1 Create a class Student, with attributes id, first name, last name. (All...

JAVA PROGRAMMING

Part 1

  1. Create a class Student, with attributes id, first name, last name. (All the attributes must be String)
    1. Create a constructor that accepts first name and last name to create a student object.
    2. Create appropriate getters and setters
  2. Create another class StudentOperationClient, that contains a main program. This is the place where the student objects are created and other activities are performed.
  • In the main program, create student objects, with the following first and last names.
  • Chris Evans
  • Mila Kunis
  • Adam Sandler
  • Emma Watson
  • Jennifer Lawrence
  • Dwayne Johnson.
  • Once you create the student objects, use System.out.println, function to print the values in following format:
  • First Name: XXXXXX , Last Name: XXXXXXXX

Part 2

3.       Create an integer attribute to student class, name it as studentScore. No getters and setters are needed for this attribute.

4.       When you create the Student object using the constructor, assign a random number to score attribute – random number should be between, 50 and 100.

5.       Create a new method in Student object, called getGrade(), that returns a String.

a.       The output method should return the following

If the score is >91, the return should be A,

Likewise B for >81 , C > 71, D > 61, and F for all others.

6.       Modify the StudentOperationsClient’s main program, to print the following.

First Name: XXXXXX , Last Name: XXXXXXXX    Letter Grade: XX

Part 3

  1. Perform the steps 2, and 6, using arrays in Java. So instead of 6 different objects, you will create an array of 6 student objects and iterate them using a for loop.
  2. Create a new method in student, getGradeDescription() – that returns a string and takes a String as input.

Use switch case control statements to return the following,

  • A – Excellent
  • B – Fair
  • C – Average
  • D – Poor
  • F – Fail,

•&νβσπ;&νβσπ;&νβσπ;&νβσπ;&νβσπ;&νβσπ;&νβσπ;&νβσπ; and any other input as “INVALID”

  • Once you create the student objects in the ARRAY, use System.out.println, function to print the values in following format:

First Name: XXXXXX , Last Name: XXXXXXXX Class Performance: <GradeDescription>

In: Computer Science

In the following code down below I am not getting my MatrixElementMult right. Could someone take...

In the following code down below I am not getting my MatrixElementMult right. Could someone take a look at it and help fix it? Also, when I print out the matrices I don't want the decimals. I know it's a format thing but I'm new to C and not getting it. Thanks!

#include <stdlib.h>
#include <stdio.h>
#include <math.h>

#define N 8

typedef struct _Matrix {
double element[N][N];
} Matrix;


void PrintMatrix(Matrix a){
int i,j;
for(i=0;i<N;i++){
for(j=0;j<N;j++){
printf(" %.1f ",a.element[i][j]);
}
printf("\n");
}
printf("\n\n");
}
float ComputeAverage(Matrix a){
int sum = 0, i,j , total = N*N;
for(i=0;i<N;i++){
for(j=0;j<N;j++){
sum += a.element[i][j];
}
}
return sum/total;
}
Matrix Add(Matrix a, int dc){
int i,j;
for(i=0;i<N;i++){
for(j=0;j<N;j++){
a.element[i][j] += dc;
}
}
return a ;
}
Matrix MatrixTranspose(Matrix a){
int i,j;
Matrix M = {{154, 123, 123, 123, 123, 123, 123, 136,
192, 180, 136, 154, 154, 154, 136, 110,
254, 198, 154, 154, 180, 154, 123, 123,
239, 180, 136, 180, 180, 166, 123, 123,
180, 154, 136, 167, 166, 149, 136, 136,
128, 136, 123, 136, 154, 180, 198, 154,
123, 105, 110, 149, 136, 136, 180, 166,
110, 136, 123, 123, 123, 136, 154, 136}};
for(i=0;i<N;i++){
for(j=0;j<N;j++){
M.element[i][j]=a.element[j][i];
}
}
return M;
}
Matrix MatrixElementDiv(Matrix a, Matrix b){
int i,j;
for(i=0;i<N;i++){
for(j=0;j<N;j++){
a.element[i][j] = a.element[i][j]/b.element[i][j];
}
  
}
return a;
}
Matrix MatrixElementMult(Matrix a, Matrix b){
int i,j;
for(i=0;i<N;i++){
for(j=0;j<N;j++){
a.element[i][j] = a.element[i][j]*b.element[i][j];
}
  
}
return b;
}

Matrix Q50 = {{16, 11, 10, 16, 24, 40, 51, 61,
12, 12, 14, 19, 26, 58, 60, 55,
14, 13, 16, 24, 40, 57, 69, 56,
14, 17, 22, 29, 51, 87, 80, 62,
18, 22, 37, 56, 68,109,103, 77,
24, 35, 55, 64, 81,104,113, 92,
49, 64, 78, 87,103,121,120,101,
72, 92, 95, 98,112,100,103, 99}
};

int main(int argc, const char * argv[])
{
Matrix M = {{154, 123, 123, 123, 123, 123, 123, 136,
192, 180, 136, 154, 154, 154, 136, 110,
254, 198, 154, 154, 180, 154, 123, 123,
239, 180, 136, 180, 180, 166, 123, 123,
180, 154, 136, 167, 166, 149, 136, 136,
128, 136, 123, 136, 154, 180, 198, 154,
123, 105, 110, 149, 136, 136, 180, 166,
110, 136, 123, 123, 123, 136, 154, 136}};
  
  
// need to implement PrintMatrix
PrintMatrix(M);
// need to implement ComputeAverage
float ave = ComputeAverage(M);
// need to implement round
int dc = round(ave);
printf("Ave = %d\n",dc);
  
// need to implement Add
Matrix M2 = Add(M, -dc);
// need to implement PrintMatrix
PrintMatrix(M2);
  
// need to implement MatrixTranspose
Matrix T2 = MatrixTranspose(M);
PrintMatrix(T2);
  
// need to implement MatrixElementMult
Matrix R = MatrixElementMult(Q50, M);
PrintMatrix(R);
  
// need to implement MatrixElementDiv
Matrix C = MatrixElementDiv(R, Q50);
PrintMatrix(C);
  
  
  
return EXIT_SUCCESS;
}

In: Computer Science

USING C# Design and implement a program (name it Coins) that determines the values of coins...

USING C#

Design and implement a program (name it Coins) that determines the values of coins in a jar. The program prints out the total dollars and cents in the jar. The program prompts the user to enter the number of coins (quarters, dimes, nickels, and pennies). Print out the number of coins entered for each coin type on separate lines followed by the total amount of money in the jar as dollars and cents as shown below.

Sample run 2:

Enter number of quarters: 3
Enter number of dimes: 0
Enter number of nickels: 0
Enter number of pennies: 3

You entered 3 quarters
You entered 0 dimes
You entered 0 nickels
You entered 3 pennies

Your total is 0 Dollars and 78 Cents.

In: Computer Science

How do I create a backup and restore strategy for a web site and the database...

How do I create a backup and restore strategy for a web site and the database for the site?

In: Computer Science

Suppose you have algorithms with the five running times listed below. (Assume these are the exact...

Suppose you have algorithms with the five running times listed below.

(Assume these are the exact running times.)

How much slower (i.e., you need check the ratio) do each of these algorithms get when
you (a) double the input size, (b) increase the input size by one?

5nlog(n)

In: Computer Science

PLEASE ANSWER USING C# Is there a Prius version? Did you know that the average Boeing...

PLEASE ANSWER

USING C#

Is there a Prius version? Did you know that the average Boeing 747 airplane uses approximately 1 gallon of fuel per second? Given the speed of the airplane, that means it gets 5 gallons to the mile. No, not 5 miles to the gallon, 5 gallons to the mile. You may be questioning why such a horribly inefficient machine is allowed to exist, but you’ll be happy to find out that, because this airplane hold 568 people, it averages about 0.01 gallons per person – (100 miles per gallon per person). Your job is to design (pseudocode) and implement (source code) a program that asks the user for a distance the plane has to fly (i.e. the length of the trip) and also asks the cost of jet fuel (which is currently $1.80 per gallon). The program should then calculate the total fuel charges to make the trip. Next, ask the user how many people will fly, as well as the average cost of a ticket. Finally, print the total profit made (or lost) and the average gas mileage per person. Document your code and properly label the input prompts and the outputs as shown below.

Sample run 1:

Enter the flight distance: 1000

Enter the current cost of jet fuel: $2 The flight will cost $10000.0 in fuel.

Enter the number of passengers: 5

Enter the average cost of a ticket: 1000

You will make a profit of $-5000.0

You averaged 1.0 miles per person per gallon!

In: Computer Science

Write a program that generates a random number between 1 and 50 and asks the user...

Write a program that generates a random number between 1 and 50 and asks the user to guess it. As a hint, it tells the user how many divisors it has, (excluding 1 and the number itself). Each time the user makes a wrong guess, it displays "Wrong" and says if the guess was too low or too high, until the user gets it right, in which case it says "Right" and says how many trials it took to guess it. Then, the program asks the user if he or she wants to continue. If the answer is 'y' or 'Y', it generates another number between 1 and 50 and repeats the game. If not, it prints the average of all trials with one decimal place and ends.

Example:

I've picked a number between 1 and 50 that has 0 divisor(s).

Guess the number: 23

Too low!

Guess the number: 37

Too low!

Guess the number: 43

Too high!

Guess the number: 41

Right! It took you 4 trials.

Play again? [y/n]: y

I've picked a number between 1 and 50 that has 1 divisor(s).

Guess the number: 25

Too low!

Guess the number: 49

Right! It took you 2 trials.

Play again? [y/n]: y

I've picked a number between 1 and 50 that has 3 divisor(s).

Guess the number: 30

Too high!

Guess the number: 24

Right! It took you 2 trials.

Play again? [y/n]: n

You averaged 2.7 trials in 3 games.

Press any key to continue.

Im stuck with the loops and if you can explain the steps would be great. At the end I need to show the average in where the user guessed the correct number and how many games they played

In: Computer Science

The Instructor class consists of a firstname (String), lastname (String), office building (String) and room number...

The Instructor class consists of a firstname (String), lastname (String), office building (String) and room number (int). There is a no-arg constructor that initializes the properties to “Albert”, “Einstein”, “McNair”, 420. There is also a constructor with a parameter for each class property. Finally, there is a toString() method that returns each property separated by an asterisk * .

  1. Create a Netbeans project and name it CourseScheduler.
  2. Implement the Instructor class in Java. Declare and instantiate two Instructor objects in the main() method of your project (one object using each constructor). Output the object properties to the console using the toString() method. When you are finished.

Problem 2 (5 points)

The Textbook class consists of a title (String), publisher (String) and edition (int). There is a no-arg constructor that initializes Strings to “” and numeric values to zero. A second constructor has formal parameters for each property. The class toString() method returns a String with each property separated by a System.lineSeparator() char.

  1. Implement the Textbook class in the CourseScheduler project. Declare and instantiate Textbook objects in the main() using both constructors. Output the object properties using the toString() method. When you are finished, get the TA to check your code to get the lab points.

Problem 3 (5 points)

The Course class consists of a name (String), semester (String), instructor (Instructor) and textbook (Textbook). As with the previous classes, there are two constructors: one no-arg constructor and one constructor with formal parameters for each property. The no-arg constructor initializes reference variables to null. The toString() method separates the name and semester by a comma (‘,’). There is a System.lineSeparator() char after the semester property and between the Instructor and Textbook properties. The Instructor and Textbook properties are formatted using the toString() method from their respective classes.

  1. Implement the Course class in the CourseScheduler project. Instantiate Instructor and Textbook objects and use them along with the course name and semester as parameters to the Course constructor. Output the properties of the Course object using the toString() method. You can verify the format of the toString() by comparing it with the file input format described in Problem 4 below. When you are finished, get the TA to check your code to get the lab points.

Problem 4 (5 points)

  1. Declare and instantiate an ArrayList in the main() method. Name it courses.
  2. Implement the following method in the same class as the main(): public static void readCourseData( ArrayList courses, String filename )
  3. Make a call to readCourseData() from the main() passing the ArrayList and the filename as parameters. Write a loop under the call to readCourseData to output all the course data to the console by calling toString() for each Course object in the ArrayList.

if you could show which part was based off of which problem, that would be helpful.

In: Computer Science

Create a Java class named ReadWriteCSV that reads the attached cis425_io.txt file that you will save...

Create a Java class named ReadWriteCSV that reads the attached cis425_io.txt file that you will save in your workspace as src/cis425_io.txt and displays the following table:
--------------------------
| No | Month Name | Days |
--------------------------
| 1 | January | 31 |
| 2 | February | 28 |
| 3 | March | 31 |
| 4 | April | 30 |
| 5 | May | 31 |
| 6 | June | 30 |.
| 7 | July | 31 |
| 8 | August | 31 |
| 9 | September | 30 |
| 10 | October | 31 |
| 11 | November | 30 |
| 12 | December | 31 |
--------------------------
Write that file out in reverse order to a file named: src/cis425_ior.txt

public class ReadWriteCSV {
// Put class properties here
// Add method, processInfile(), to open file and read here
   void processInfile()
   {
       File filename = new File ("cis425_io.txt");
       Scanner in = new Scanner(System.in); // System.in is an InputStream
       Scanner inFile = new Scanner("cis425_io.txt");
   }
// add method, displayTable(), here to display the table
   void displayTable() {
      
   }
// add method, writeOutfile(), here to open and write the data in reverse order to the new file
   void writeOutfile() {
      
   }
// add main() method here
   public static void main(String[] args) {
      
   }
}

In: Computer Science

use C++ You will implement the following encryption and decryption functions/programs for the Caesar cipher. Provide...

use C++

You will implement the following encryption and decryption functions/programs for the Caesar cipher. Provide the following inputs and outputs for each function/program:

EncryptCaesar

  • Two inputs:

    • A string of the plaintext to encrypt

    • A key (a number)

      ▪ For the Caesar cipher: This will indicate how many characters to shift (e.g. for a key=3, A=>D, B=>E, ..., X=>A, Y=>B, Z=>C). Note that the shift is circular.

  • One output:
    ◦ A string of the ciphertext or codeword

    DecryptCaesar

  • Two inputs:
    ◦ A string of the ciphertext to decrypt ◦ The key (a number)

  • One output:
    ◦ A string of the plaintext

    Obviously, for this assignment to be successful, the decryption function/program must decrypt the original message which was encrypted by the encryption function/program. Or, for a plaintext P and an encryption function E() and a decryption function D(), P = D( E(P, Key), Key)

In: Computer Science

Create the appropriate variables and algorithm to calculate the following. Choose your own values for the...

Create the appropriate variables and algorithm to calculate the following. Choose your own values for the variables. Do not enter the code on this paper. Create a program that calculates and displays the calculation. Approximate pi (π) as 3.14159.

You do not need to create a new program for each question.

If certain math equations use the same variable name, then you only need to declare it once in your main function.

Separate each problem using comments, like seen in the example below.

Example 1: Area of a square/rectangle. Formula:

int main()

{

   // Example 1

float area, length, width;

length = 20;

width = 5;

area = length * width;

cout << "The area of a square with length " << length << " and width "

   << width << " is " << area << " square units.";

// Problem 1

// Problem 2

return 0;

}

  1. Area of triangle.

  1. Area of circle. Formula:

  1. Area of rhombus. Formula:

  1. Area of trapezoid. Formula:

  1. Area of a parallelogram. Formula:

  1. Volume of sphere. Formula:

  1. Volume of cone. Formula:

  1. Volume of cube. Formula:

  1. Volume of cylinder. Formula:

  1. Volume of square pyramid. Formula:

  1. Volume of pyramid. Formula:

  1. Perimeter of Rectangle. Formula:

  1. Midpoint. Formula:

  1. Calculate Absolute Value. i.e.:

  1. Slope. Formula:

  1. Parabola Axis of Symmetry. Formula:

  1. Sum and Difference of Cubes.
    • Sum:
    • Difference:

In: Computer Science

Translate the following C code to MIPS assembly. int a = 1; int b = 2;...

  1. Translate the following C code to MIPS assembly.

int a = 1;

int b = 2;

if (a<b)

          a=a+1;

b = b + a;

printf("The value of b is: %d", b);

  1. Translate the following C code to MIPS assembly.

int a = 2;

int b = 2;

if (a<b)

          a=a+1;

else

          a=a-1;

b = b + a;

printf("The value of b is: %d", b);

In: Computer Science

Suggest ways how to increase the number of visits for a website?

Suggest ways how to increase the number of visits for a website?

In: Computer Science

c programming Proxy IP addresses and port number are following [Ref-1] 191.96.43.58:3129 136.25.2.43:49126 198.211.96.170:3129 198.1.122.29:80 Note:...

c programming

Proxy IP addresses and port number are following [Ref-1]

191.96.43.58:3129

136.25.2.43:49126

198.211.96.170:3129

198.1.122.29:80

Note: THE STRING FORMATE IS "IP_Address:Port_Number ". For example, "191.96.43.58:3129" includes an IP address and a port number. "191.96.43.58" is the IP address; "3129" is the port number.

Write a program using C Structures.

If port number is 3129, please identify these IP addresses.

In: Computer Science

Let t = [1:60]; x = [68 126 86 71 100 177 233 271 206 269...

Let t = [1:60];

x = [68 126 86 71 100 177 233 271 206 269 340 269 315 384 431 467 382 440 511 558 565 529 511 551 682 665 642 671 796 774 749 758 796 834 878 896 847 836 872 925 978 981 989 1041 1070 1067 1138 1167 1167 1167 1167 1194 1245 1196 1167 1165 1167 1196 1167 1134];

y =-[238 226 189 238 295 231 184 240 289 235 195 231 295 249 184 189 244 291 246 233 193 193 246 289 115 35 273 298 111 33 44 286 280 242 238 193 191 242 291 271 184 293 233 182 211 289 242 209 80 160 278 298 246 298 275 206 155 153 157 162];

1. Use cubic splines with clamped conditions to fit the data t and y.

2. Let tt=linspace(t(1),t(end),200); and evaluate the cubic spline at tt and assign the result to a variable called y1.

3. Find spline (from 1) at 45.

4. Use cubic splines with not-a-knot conditions to fit the data t and x.

5. Let tt=linspace(t(1),t(end),200); and evaluate the cubic spline at tt and assign the result to a variable called x1.

6.Plot the x1 (from part 5) against y1 (from part 2). Describe the resulting plot and show your MATLAB code and plots.

In: Computer Science