Questions
Have a pretty good idea on how to solve this program, I'm just not very accustomed...

Have a pretty good idea on how to solve this program, I'm just not very accustomed to formatting well in Java for these types of problems. In java, you have full control of what's printed, I just need to get better at it, so I thought I'd post it here to receive an answer to learn from. Thanks for everything guys.

This program must use the Exclusive OR Operator ^ in java, it must also use a while loop. The way it wants to be formatted is also listed.

Write a program that uses a while loop to detect and print multiples of 19 or 23, but not both. Use the exclusive or operator as on page 93. The program should start examining integers at 100, and examine successively larger integers until 15 multiples have been detected. Correct multiples should be printed right aligned in fields that are 6 characters wide, but with only five multiples per line. The total of all correct multiples should be reported after 15 multiples have been printed.

In: Computer Science

1. How does eBay’s original business model contrast with its current business model?

1. How does eBay’s original business model contrast with its current business model?

In: Computer Science

Discussion: Cloud Computing in 200 words Discuss Cloud Computing. Give an example of cloud computing. Conduct...

Discussion: Cloud Computing in 200 words

  1. Discuss Cloud Computing. Give an example of cloud computing.
  2. Conduct a little research on cloud computing and list pros and cons of using Cloud Computing
  3. Do you feel safe storing your information on Cloud

In: Computer Science

SQL Questions 1. Select ALL of the TRUE statements. a. You can control the location of...

SQL Questions

1. Select ALL of the TRUE statements.

a. You can control the location of objects within a database onto specific disks/SAN LUNs only if multiple filegroups are created for each disk or SAN LUN

b. Dirty pages are data pages that have been updated in memory, but not yet written to disk
c. DBCC CHECKDB should be executed at all times to ensure data integrity

d. SQL Server data files and log files perform best on network shares as opposed to locally connected drives

e. Filegroups apply only to data files and not to log files

f. SQL Server always writes to the transaction log on disk before any data page is updated in the memory buffers
g. A SQL Server data file can be a part of multiple filegroups

2. SQL Server 2008 SP4 Enterprise Edition can be upgraded to which of the following SQL Server 2017 editions?

a. SQL Server 2017 Developer Edition

b. SQL Server 2017 Standard Edition

c. SQL Server 2017 Enterprise Edition

d. SQL Server 2017 Express Edition

3. SQL Server 2017 supports compatibility mode for which of the following versions of SQL Server?

Select one or more:

a. SQL Server 2008 R2
b. SQL Server 2005

c. SQL Server 2012

d. SQL Server 2014
e. SQL Server 2008

4. Which of the following statements are true in SQL Server?

Select ALL that apply:

a. SQL Server data files can only grow in multiples of 64K

b. You must pay for all editions of SQL Server

c. Server-side networking for SQL Server is configured at the Database level

d. It is best practice to set Auto_Update_Statistics & Auto_Create_Statistics to FALSE

e. A data page in SQL Server can only hold one object (e.g. a specific table, index, etc.)

f. SQL Server pages can be any size between 8K and 64K

g. You can have multiple versions of SQL Server installed on the same virtual server

5. Which of the following SQL Statements that will provide a list of all tables in the 'AdventureWorks2014" database and nothing else?

Group of answer choices

a. use AdventureWorks2014; Select * from sys.objects where type='TABLE'

b. use AdventureWorks2014; SELECT * FROM INFORMATION_SCHEMA.Tables WHERE TABLE_TYPE = 'BASE TABLE'

c. use AdventureWorks2014; Select * from INFORMATION_SCHEMA.TABLES

d. use AdventureWorks2014; Select * from system.tables

In: Computer Science

This question is about the class Set, as discussed in the lectures. It represents a finite...

This question is about the class Set, as discussed in the lectures. It represents a finite set of int’s. Relevant parts of Set are shown below. The integer count holds the number of elements in the Set. The array elements holds the elements themselves. The class Set also has public methods addElement, equals, isIn, and toString. They are defined as in the lectures, and you can use them if you need to.

class Set  

{  

  private int count;  

  private int [] elements;  

}

Write a public method for Set called both that takes another Set as its only parameter. The method both must return the number of elements that are in both Set’s.

For example, suppose that s1 is an instance of Set with elements 0, 2, 3, and 5. Also suppose that s2 is an instance of Set with elements 0, 1, 3, 4, and 11. Then s1.both(s2) must return 2, because there are two elements 0 and 3 that are in both sets. This is only an example! For full credit, your method both must work for any Set’s, not just the ones mentioned here.

In: Computer Science

Add bubble sort, radix sort, insertion sort, and merge sort to the code provided. Import a...

Add bubble sort, radix sort, insertion sort, and merge sort to the code provided.

Import a data set (txt file) then do the sorting algorithm to measure how long it took and how many movements occurred.

Please write codes in C++

Here's data set (should be stored in txt file)

7426
4524
4737
9436
3997
2757
6288
5414
9590
5968
6638
3199
9514
1541
9866
2144
6731
911
2171
6135
6437
912
9417
2662
6606
6349
707
2890
5386
9718
3492
5068
9674
8578
8323
7789
4748
7576
2664
6352
7967
8556
4740
5737
6764
368
1070
3700
1291
5279
9429
9507
2575
3099
2147
9660
2515
2976
4086
8305
6913
1308
7123
7678
8971
7507
139
51
5980
1100
3976
7289
9249
1662
8659
2758
3605
1079
7829
2298
3671
8901
1176
9089
3350
7500
6702
8903
5279

Here's the code

#include <bits/stdc++.h>
using namespace std;
using namespace std :: chrono;
#define MAX 1000

void selectionSort(int arr[], int n)
{
int i, j;

for (j = 0; j < n - 1; j++) {
int iMin = j;

for (i = j + 1; i < n; i++) {
if (arr[i] < arr[iMin]) {
iMin = i;
}
}

if (iMin != j) {
int temp = arr[j];
arr[j] = arr[iMin];
arr[iMin] = temp;
}
}
}

void quickSort(int arr[], int first_index, int last_index)
{
int pivotIndex, temp, index_a, index_b;

if (first_index < last_index) {
pivotIndex = first_index;
index_a = first_index;
index_b = last_index;

while (index_a < index_b) {
while (arr[index_a] <= arr[pivotIndex] && index_a < last_index) {
index_a++;
}
while (arr[index_b] > arr[pivotIndex]) {
index_b--;
}

if (index_a < index_b) {
temp = arr[index_a];
arr[index_a] = arr[index_b];
arr[index_b] = temp;
}
}

temp = arr[pivotIndex];
arr[pivotIndex] = arr[index_b];
arr[index_b] = temp;

quickSort(arr, first_index, index_b - 1);
quickSort(arr, index_b + 1, last_index);
}
}


void shellSort(int arr[], int n)
{
int j;

for (int gap = n / 2; gap > 0; gap /= 2) {
for (int i = gap; i < n; ++i) {
int temp = arr[i];
for (j = i; j >= gap && temp < arr[j - gap]; j -= gap) {
arr[j] = arr[j - gap];
}
arr[j] = temp;
}
}
}

int main()
{
int arr[MAX], i = 0, size = 0;

ifstream file("data.txt");

while (!file.eof())
{
file >> arr[i];
i++;
}

size = i;

// selection sort
auto startSel = high_resolution_clock :: now();
selectionSort(arr, size);
auto stopSel = high_resolution_clock :: now();
auto durationSel = duration_cast<microseconds>(stopSel - startSel);
cout << "Time taken by selection sort: " << durationSel.count() << " microseconds" << endl;

// quick sort
auto startQuick = high_resolution_clock :: now();
quickSort(arr, 0, size - 1);
auto stopQuick = high_resolution_clock :: now();
auto durationQuick = duration_cast<microseconds>(stopQuick - startQuick);
cout << "Time taken by quick sort: " << durationQuick.count() << " microseconds" << endl;

// shell sort
auto startShel = high_resolution_clock :: now();
shellSort(arr, size);
auto stopShel = high_resolution_clock :: now();
auto durationShel = duration_cast<microseconds>(stopShel - startShel);
cout << "Time taken by shell sort: " << durationShel.count() << " microseconds" << endl;

return 0;
}


In: Computer Science

Java Please Source Only Program 3: Distance calc. This question is fairly straightforward. Design (pseudocode) and...

Java Please

Source Only

Program 3: Distance calc. This question is fairly straightforward. Design (pseudocode) and implement (source code) a program to compute the distance between 2 points. The program prompts the user to enter 2 points (X1, Y1) and (X2, Y2). The distance between 2 points formula is: Square_Root [(X2 – X1)^2 + (Y2 – Y1)^2] Document your code, properly label the input prompts, and organize the outputs as shown in the following sample runs.

In: Computer Science

Write bash shell scripts for the following problems and submit your answers a single. A )...

Write bash shell scripts for the following problems and submit your answers a single.

A ) Write a linux bash shell script that reads your first and lastname as arguments and print them as shown below. In my example, I name the script as printname.sh. In the example, the two arguments follow the shell scriptname. Submit the script and output print screen.

# sh ./printname.sh Abdullah Konak 
My first name is Abdullah
My surname is Konak

B ) Write a linux bash script that will return the largest of the two numbers that are entered as the argument of the script as shown in the example given below. Return your script and a printscreen from your computer.

# sh ./larger.sh 7 5 
7 is larger of 5 and 7.

C) Extend the script in part B to any number of numbers entered as arguments as the example given below.

# sh ./largest.sh 7 5 3 8 9 10
10 is the largest of numbers entered. 

In: Computer Science

I am trying to get this code to work but I am having difficulties, would like...

I am trying to get this code to work but I am having difficulties, would like to see if some one can solve it. I tried to start it but im not sure what im doing wrong. please explain if possible

package edu.hfcc;

/*
* Create Java application that will create Fruit class and Bread class
*
* Fruit class will have 3 data fields name and quantity which you can change.
* The third data field price should always be 2.0
* Bread class will have 3 data fields name, quantity and price. All three data fields can change.
*
* Create method that creates the string used write to console and return from execute()
*
* In GroceryApp
* Create method to calculate totalPrice for fruit
* Create method to calculate totalPrice for bread
* Create method to print to console use EXACLTY like example below
*
* Data to use
* Bread:     Name=French,    Quantity=2,   Price=3.0
* Fruit:   Name=Apple,    Quantity=5,   
*
* EXAMPLE TO Console
* French
        2 @ 3.0       6.0
Apple
      5 @ 2.0       10.0
---------------------
                   16.0
*/

public class Grocery {

   private static final char NEW_LINE = '\n';
   private static final String TAB = "\t";
  
   public String execute(){
      
       Fruit fruitOne = new Fruit();
       fruitOne.setName("Apple");
       fruitOne.setQuantity( 5);
      
       String fruits = constructOutputFruit(apple);
       System.out.println(fruits);

       return fruits;
   }
   private String constructOutputFruit(Fruit fruit1) {
       String apple = fruit1.getName() + NEW_LINE + fruit1.getQuantity() + TAB + fruit1.getPrice();
      
       return apple + NEW_LINE;
   }
}

here are my classes:

Fruit:

package edu.hfcc;

public class Fruit {

   private String name;
   private int quantity;
   private float price;
  
   public Fruit(){
       this.price = (float)2.0;
       }
  

   public String getName() {
       return name;
   }

   public void setName(String name) {
       this.name = name;
   }

   public int getQuantity() {
       return quantity;
   }

   public void setQuantity(int quantity) {
       this.quantity = quantity;
   }

   public float getPrice() {
       return price;
   }
}

Bread:

package edu.hfcc;

public class Bread {

   private String name;
   private int quantity;
   private float price;
   public String getName() {
       return name;
   }
   public void setName(String name) {
       this.name = name;
   }
   public int getQuantity() {
       return quantity;
   }
   public void setQuantity(int quantity) {
       this.quantity = quantity;
   }
   public float getPrice() {
       return price;
   }
   public void setPrice(float price) {
       this.price = price;
   }
  

}

In: Computer Science

JAVA please Program 4: Is there a Prius version? Did you know that the average Boeing...

JAVA please

Program 4: 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.

In: Computer Science

In the second task, you will write a Java program that validates an input to see...

In the second task, you will write a Java program that validates an input to see whether it matches a specified pattern. You will have to read a bit about regular expressions for this Lab.

1. Prompt the user to enter the email address.

2. Read the user input as a String.

3. A regular expression that specifies the pattern for an email address is given by “[a-zA-Z0- 9.]++@[a-zA-Z]++.(com|ca|biz)”. Use this as the input to the matches method in the String class and output the result returned by the method.

4. Prompt the user to enter the full name.

5. Full name should have First name, zero or Middle names and the Last name. For this purpose, we will assume a name (first, middle or last) is a set of characters without any spaces. Some examples are “John”, “McDonald”, “smiTh”. The names are separated by exactly one space. Write a regular expression to represent this pattern.

6. Use the matches method in the String class to validate the name entered by the user and output the result returned by the method.

A possible dialogue with the user might be;

Please enter the email address: [email protected]

true

Please enter the full name: Malaka Second Third Walpola

true

In: Computer Science

Question 1 (10) Create a class Student with public member variables: Student name, student number, contact...

Question 1 (10)
Create a class Student with public member variables: Student name, student number, contact number, ID number. The following specifications are required:
 Add init() method of the class that initializes string member variables to empty strings and numeric values to 0. (2)
 Add the method populate() to the class. The method is used to assign values to the member variables of the class. (2)
 Add the method display() to the class. The method is used to display the member variables of the class. (2)
 Create an instance StudentObj of the class Student in a main program. (2)
 The main program should prompt the user to enter values for five students. The attributes should be assigned to the instance of Student using its populate() method, and must be displayed using the display() method of the instance of Student. (2)

Please make the answer simple and straightforward for a beginner intro to python . Thank you

In: Computer Science

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