Questions
Create a Java program that will encrypt a message and decryted a message and it must...

Create a Java program that will encrypt a message and decryted a message and it must be save to a disk file.

In: Computer Science

I'm working on a python programming problem where I have to write a program that plays...

I'm working on a python programming problem where I have to write a program that plays rock paper scissors.

our program will allow a human user to play Rock, Paper, Scissors with the computer. Each round of the game will have the following structure:

  • The program will choose a weapon (Rock, Paper, Scissors), but its choice will not be displayed until later so the user doesn’t see it.
  • The program will announce the beginning of the round and ask the user for his/her weapon choice
  • The two weapons will be compared to determine the winner (or a tie) and the results will be displayed by the program
  • The next round will begin, and the game will continue until the user chooses to quit
  • The computer will keep score and print the score when the game ends

The computer should select the weapon most likely to beat the user, based on the user’s previous choice of weapons. For instance, if the user has selected Paper 3 times but Rock and Scissors only 1 time each, the computer should choose Scissors as the weapon most likely to beat Paper, which is the user’s most frequent choice so far. To accomplish this, your program must keep track of how often the user chooses each weapon. Note that you do not need to remember the order in which the weapons were used. Instead, you simply need to keep a count of how many times the user has selected each weapon (Rock, Paper or Scissors). Your program should then use this playing history (the count of how often each weapon has been selected by the user) to determine if the user currently has a preferred weapon; if so, the computer should select the weapon most likely to beat the user’s preferred weapon. During rounds when the user does not have a single preferred weapon, the computer may select any weapon. For instance, if the user has selected Rock and Paper 3 times each and Scissors only 1 time, or if the user has selected each of the weapons an equal number of times, then there is no single weapon that has been used most frequently by the user; in this case the computer may select any of the weapons.

At the beginning of the game, the user should be prompted for his/her input. The valid choices for input are:

  • R or r (Rock)
  • P or p (Paper)
  • S or s (Scissors)
  • Q or q (Quit)

At the beginning of each round your program should ask the user for an input. If the user inputs something other than r, R, p, P, s, S, q or Q, the program should detect the invalid entry and ask the user to make another choice.

Your program should remember the game history (whether the user wins, the computer wins, or the round is tied).

At the end of the game (when the user chooses ‘q’ or ‘Q’), your program should display the following:

  • The number of rounds the computer has won
  • The number of rounds the user has won
  • The number of rounds that ended in a tie
  • The number of times the user selected each weapon (Rock, Paper, Scissors)

In: Computer Science

Hey guys, I have my assignment due for Coding on next Friday. There were 2 parts...

Hey guys,

I have my assignment due for Coding on next Friday. There were 2 parts of assignment, part 1 was about User Interface (CUI), File I/O, Software Functionality and others without GUI. This includes OOP. Anyways 2nd part of our assignment includes GUI And other advanced features that we have to implement on our previous program. I'm happy to send you the exact details of whats required for assignment 2. Anyways, I've done the first part, and All I'm asking is that would you still take $7.90 NZD because all that's need to be added is GUI. I have about 5 classes I think. So what do you think? My topic is Who Wants To Be A Millionaire! Basic millionaire code!


In: Computer Science

The restaurant maintains the catalog for the list of food and beverage items that it provides....

The restaurant maintains the catalog for the list of food and beverage items that it provides. Apart from providing food facility at their own premises, the restaurant takes orders online through their site. Orders on the phone are also entertained. To deliver the orders, we have delivery boys. Each delivery boy is assigned to the specific area code. The delivery boy cannot deliver outside the area which is not assigned to the delivery boy (for every delivery boy there can be a single area assigned to that delivery boy). The customer record is maintained so that premium customer can be awarded discounts.

Need copy of code and a report if possible.

Code is Python.

In: Computer Science

x = [0,1,2,3,4,5,6,7,8]; y = [0,10,23,28,25,13,6,2,-5]; Spline interpolation, Use Matlab code Write your own spline method...

x = [0,1,2,3,4,5,6,7,8];
y = [0,10,23,28,25,13,6,2,-5];

Spline interpolation, Use Matlab code
Write your own spline method to estimate the value of the function on x ∈ [0,8],Δx = 0.1. For your 2 degrees of freedom, set the first and second
derivatives at the left boundary to 0. Save your result, the interpolated y values.(do not use Matlab's built-in spline method

In: Computer Science

C++ Coding ****** Please read prompt carefully and include screenshots fro verification. Start with a Person...

C++ Coding ****** Please read prompt carefully and include screenshots fro verification.

Start with a Person class, and create a multiset to hold pointers to person objects. Define the multiset with the comparePersons function object, so it will be sorted automatically by names of person. Define a half-dozen persons, put them in the multiset, and display its contents. Several of the persons should have the same name, to verify that multiset stores multiple object with the same key. Also allow the user to search a person object by the last name and the first name.

In: Computer Science

JAVA LANGUAGE coding required. You are to take the payroll file called DeweyCheatemAndHow.txt to use as...

JAVA LANGUAGE coding required.

You are to take the payroll file called DeweyCheatemAndHow.txt to use as input to your program and produce a file that lists all the employee and their gross pay. At the end of the file you are to show the average gross pay for each type of employee.

In order to do this, you will need to create the following classes:

Employee:

            Attribues:

                        First name

                        Last name

                        Address

                        Phone

                        SSN

            Methods:

                        Appropriate constructors

                        Set methods for first name, last name, ssn

                        Get methods for last name, first name, ssn, address, phone

                        toString

                        Equals

                        

Salaried:  (Child of Employee)

            Attributes:

                        Salary

            Methods

                        Appropriate constructors

                        Set methods for Salary

                        Get methods for Salary

                        toString

                        Pay

Hourly:  (Child of Employee)

            Attributes:

                        Pay rate

                        Hours worked

            Methods

                        Appropriate constructors

                        Set methods for pay rate, hours worked

                        Get methods for pay rate, hours worked

                        toString

                        Pay

Piece:  (Child of Employee)

            Attributes:

                        Quantity

                        Piece rate

            Methods

                        Appropriate constructors

                        Set methods for Quantity, Piece rate

                        Get methods for Quantity, Piece rate

                        toString

                        Pay

Each line in the file start with a single letter that represents whether the employee is salaried, hourly or piece rate.    The letters are s for salaried, h for hourly and p for piece rate. Below is an example of what each line will look like:

Code ssn first name last name address phone salary

s 123-45-6789 William Tell 1313 Mockingbird lane 513-556-7058 500.75

Code ssn first name last name address phone pay rate hours worked

h 123-45-6789 Scott Tell 1313 Mockingbird lane 513-556-7058 10 40.0

Code ssn first name last name address phone pay per piece number of pieces

p 123-45-6789 Chris Stevens 1313 Mockingbird lane 513-556-7058 7.50 1000

You are to process all the entries provided in the file and produce output that looks like this:

Dewey, Cheatem and How Law Firm

Payroll Report

First Name Last Name SSN  Gross Pay $XXX.

First Name Last Name SSN  Gross Pay $XXX.

First Name Last Name SSN  Gross Pay $XXX.

First Name Last Name SSN  Gross Pay $XXX.

First Name Last Name SSN  Gross Pay $XXX.

First Name Last Name SSN  Gross Pay $XXX.

First Name Last Name SSN  Gross Pay $XXX.

.

.

.

Average salaried employee gross pay:    $XXX

Average hourly employee gross pay:     $XXX

Average pieces employee gross pay:    $XXX

Please note that for this assignment you are to use the data in the file below as the source to input into your program but that the inputting is to be handled by your program prompting the user to input the information. The next assignment will address inputting directly from a file.

s 028-13-3948 Andrew Smith 1313 Mockingbird Lane 513-556-7000 500.75
s 028-24-9971 Andrew Whaley 1776 Liberty Ave 513-556-7001 675
h 112-45-7867 Saif Altarouti 3427 Smith Rd 513-556-7002 20 40
s 123-45-6789 Nicholas Alonso 920 Ohio Ave 513-556-7003 900
s 123-94-3938 Abigail Smith 1600 Penn St 513-556-7004 1200
h 123-97-4556 Matthew Stewart 2925 Campus Green 513-556-7005 16.5 40
s 142-78-2367 Syeda Mullen 345 Ludlow Ave 513-556-7006 763
p 143-49-0923 Arianna Rhine 768 Stratford Dr 513-556-7007 7.5 1000
p 193-93-1283 Emmalese Nuerge 132 Greyfox Rd 513-556-7008 8.5 1010
p 211-54-823 Joshua Ayers 671 Buckwheat Rd 513-556-7009 5.5 500
h 258-29-9102 Nicholas Roth 734 Student Dr 513-556-7010 25 35

In: Computer Science

2 Builder Pattern java -set up builder pattern to run this RobotBuilder builder = new RobotBuilder();...

2 Builder Pattern
java
-set up builder pattern to run this 

RobotBuilder builder = new RobotBuilder();
builder.setRam(1000);
builder.setStorage(10000);
builder.setWheels(2);
builder.setName("Robo Ron");
Robot robot = builder.build();

builder = new RobotBuilder();
builder.setName("Robo Rene");
builder.setRam(500);
builder.setStorage(15000);
Robot robot2 = builder.build();

In: Computer Science

This is meant to be done in C. Write a program using putchar() and getchar() that...

This is meant to be done in C. Write a program using putchar() and getchar() that reads characters form the keyboard and write to the screen. Every letter that is read should be written three times and followed by a newline. Any newline that is read should be disregarded. All other characters should just be copied to the screen.

I am stuck on this any help please?

In: Computer Science

I need to know how to build a flag in c++ for Italy

I need to know how to build a flag in c++ for Italy

In: Computer Science

Write a program in python that opens a text file, whose name you enter at the...

Write a program in python that opens a text file, whose name you enter at the keyboard.

•You will be using the file filetext.txt to test your program

•Print out all of the individual, unique words contained in the file, in alphabetical order.

MAKE SURE THAT ALL THE WORDS YOU PRINT OUT ARE IN A SINGLE COLUMN, ONE WORD PER COLUMN!•Print out the number of unique words appearing in text.txt

In: Computer Science

First level CS, should not be too complex. Need in a week. You must turn in...

First level CS, should not be too complex. Need in a week.

You must turn in three java files - FoodItem.java, Order.java and MyOrder.java. In addition to these, you must include a screenshot of the output by executing the file MyOrder.java. Submissions without all these files will not be graded.

Task 1:

Design a class named FoodItem which contains the following fields:

Type of food item: Like entree, bread, soup, salad, drink or dessert to name a few

Item number: could be an alphanumeric code or just a number

Unit price: $xx.xx

You must include appropriate instance methods like constructors, getters , setters and toString for all the fields.

Task 2:

Create another class named Order which has the following fields:

Order number: It could be an alphanumeric id or numeric.

Customer Name: First and last name of the customer

Combo meal option: yes or no

DiscountAmount: If combo meal is chosen, offer a 5% discount

OrderTotal: Total bill amount

You must create the following methods for the Order class:

Constructor (s) - You may include an extra constructor that takes in the Customer name as a parameter.

Setters, getters and toString methods for the appropriate fields.

add(item,quantity) - this method adds the price of purchasing an item to the Order total.

getOrderTotal() - this method returns the total bill amount to be paid by the customer after including any discounts applicable and also a 10% sales tax on the total amount.

Task 3:

Create a class named MyOrder that displays a Menu of items available to choose from, creates an order for two different customers and reports their total bill amount. Use appropriate print statements to guide the user through the ordering process. Remember, this is the class where you are actually placing an order (action required). So, this class must contain the main method.

In: Computer Science

Assume that the cache size is 256kB, and each cache line is 64 Bytes. (10%) Let...

  1. Assume that the cache size is 256kB, and each cache line is 64 Bytes. (10%)
  1. Let us assume this is a Two-way associative cache. How many cache sets are there?

  1. Let us assume the following memory blocks need to be accessed:

Memory Blocks #4100, 8196, 2052, 8196, 2052, 4100

If the cache is initially empty, what is the cache hit/miss rate?

In: Computer Science

How can i quit this python program. #******************************************************************************** #Program : SearchClassInfo.py #Description: This program will ask...

How can i quit this python program.

#********************************************************************************
#Program : SearchClassInfo.py

#Description: This program will ask a user to enter 6 courses and will allow him
# to search a class by course number, room number, intructor or time,
# the program will run until the user stop it.
#********************************************************************************
from os import sys
def main():
#Definition of 4 lists
courses = []
rooms = []
instructors = []
times = []
#Allow user to enter six courses
for x in range(2):
Course_Number =input('Enter the course number: ')
Room_Number = input('Enter a room number: ')
Instructor =input('Enter the Instructor of the course: ')
Time = input('Enter the time the course meets: ')
#Add elements in appriate list.
courses.append(Course_Number)
rooms.append(Room_Number)
instructors.append(Instructor)
times.append(Time)


loop = 1 #initialisation of a flag.

while loop != 0:
try:
#Display a menu of four choices to make to search a class.
print('\nEnter 1 to search by course number: ')
print('Enter 2 to search by room number: ')
print('Enter 3 to search by instructor: ')
print('enter 4 to search by time: ')

choice = int(input('Enter your choice: '))#ask user to enter his choise for search.

if choice == 1 :
#ask user to enter course number for search of corresponding elements.
Course_Number = input('Enter a course number: ')
if Course_Number in courses: #verify if the couse number entered is in the list
#extract the index of the course number in list.
i=courses.index(Course_Number)
#printing elements on the same index as course number in other lists.
print('\nThe detail for course',courses[i], 'are:'
'\nRoom:', rooms[i],
'\nInstructor:',instructors[i],
'\nTime:',times[i], end=' ''\n')
else:#message to alerte when course number does not exit
print('\nThis course number is not on schedule')
  
elif choice == 2 :
# #ask user to enter room number for search of corresponding elements.
Room_Number = input('Enter a room number: ')
if Room_Number in rooms:#verify if the room number entered is in the list
#extract the index of the room number in list.
i=rooms.index(Room_Number)
#printing elements on the same index as room number in other lists.
print('\nThe detail for course',courses[i], 'are:'
'\nRoom:', rooms[i],
'\nInstructor:',instructors[i],
'\nTime:',times[i], end=' ' '\n')
else:#message to alerte when room number does not exit
print('\nThis room number is not on schedule')

elif choice == 3 :
Instructor = input('Enter the Instructor of the course: ')
if Instructor in instructors:
i=instructors.index(Instructor)
print('\nThe detail for course',courses[i], 'are:'
'\nRoom:', rooms[i],
'\nInstructor:',instructors[i],
'\nTime:',times[i], end=' ' '\n')
else:
print('\nThis instructor is not on schedule')
  
elif choice == 4 :
Time = input('Enter the time the course meets: ')
if Time in times:
i=times.index(Time)
print('\nThe detail for course',courses[i], 'are:'
'\nRoom:', rooms[i],
'\nInstructor:',instructors[i],
'\nTime:',times[i], end=' ' '\n')
else:
print('\nThis time is not on schedule')
  
elif choice!=' ':
print('Choice goes from 1--->4')
loop = 0
  


print('\nDo you want to continue? Enter y for yes')
control = input(' ')

if control == 'y'or'Y':
loop = 1

elif control!=' ':
sys.exit(0)

except:
print('incorrect choice, must be 1,2,3 or4')
pass
  
main()

In: Computer Science

OpenACC. Insert OpenACC directives to improve the performance only within the matmul function. Enhance the comments...

OpenACC.

Insert OpenACC directives to improve the performance only within the matmul function. Enhance the comments throughout.

Clearly identify, in your report, the execution time of your implementation the algorithm. How large do the matrices need to be before the performance of a P100 exceeds that of 28 cores on Bridges (using square matrices with power of two order)?

///////////////////////////////////////////////////////////////////////////////
// matmul.c
//
// Procedures:
//
// main   generates matrices and tests matmul
// matmul   basic, brute force matrix multiply
///////////////////////////////////////////////////////////////////////////////

#include <stdio.h>
#include <sys/time.h>

///////////////////////////////////////////////////////////////////////////////
// int main( int argc, char *argv[] )
// Description: Generates two matrices and then calls matmul to multiply them.
//    Finally, it verifies that the results are correct.
//
// Parameters:
//   argc   I/P   int   The number of arguments on the command line
//   argv   I/P   char *[]   The arguments on the command line
//   main   O/P   int   Status code
///////////////////////////////////////////////////////////////////////////////
#ifndef L
#define L (1*1024/1)
#endif
#ifndef M
#ifdef SQUARE
#define M L
#else
#define M (1*1024/1)
#endif
#endif
#ifndef N
#ifdef SQUARE
#define N L
#else
#define N (1*1024/1)
#endif
#endif
float A[L*M], B[M*N], C[L*N];

int matmul( int l, int m, int n, float *A, float *B, float *C );

int main( int argc, char *argv[] )
{
   int i, j, k;

#ifdef OMP
#pragma omp parallel
{
   int np = omp_get_num_procs();
   fprintf( stderr, "Threads = %d\n", np );
}
#endif

   for( i=0; i<L; i++ )
   for( j=0; j<M; j++ )
   {
   if( i <= j )
   {
       A[i*M+j] = (float) (i*M+j+1);
   }
   else
   {
       A[i*M+j] = 0.0;
       A[i*M+j] = (float) (i*M+j+1);
   }
   }

   for( j=0; j<M; j++ )
   for( k=0; k<N; k++ )
   {
   if( j <= k )
   {
   if( k < M )
       B[j*N+k] = 1.0;
   else
       B[j*N+k] = B[j*N+k-1] + 1.0;
   }
   else
   {
       B[j*N+k] = 0.0;
   }
   }

   for( i=0; i<L; i++ )
   for( k=0; k<N; k++ )
   {
   C[i*N+k] = - (float) L*M*N;
   }

   struct timeval start, stop;
   gettimeofday( &start, NULL );
   matmul( L, M, N, A, B, C );
   gettimeofday( &stop, NULL );
   float elapsed = ( (stop.tv_sec-start.tv_sec) +
           (stop.tv_usec-start.tv_usec)/(float)1000000 );

   float flops = ( 2 * (float)L * (float)M * (float)N ) / elapsed;

   printf( "L=%d, M=%d, N=%d, elapsed=%g, flops=%g\n",
       L, M, N, elapsed, flops );

#ifdef DEBUG
   printf( "A:\n" );
   for( i=0; i<L; i++ )
   {
   printf( "%g", A[i*M] );
   for( j=1; j<M; j++ )
   {
   printf( " %g", A[i*M+j] );
   }
   printf( "\n" );
   }

   printf( "B:\n" );
   for( j=0; j<M; j++ )
   {
   printf( "%g", B[j*N] );
   for( k=1; k<N; k++ )
   {
   printf( " %g", B[j*N+k] );
   }
   printf( "\n" );
   }

   printf( "C:\n" );
   for( i=0; i<L; i++ )
   {
   printf( "%g", C[i*N] );
   for( k=1; k<N; k++ )
   {
   printf( " %g", C[i*N+k] );
   }
   printf( "\n" );
   }
#endif
}

///////////////////////////////////////////////////////////////////////////////
// int main( int argc, char *argv[] )
// Description: Generates two matrices and then calls matmul to multiply them.
//    Finally, it verifies that the results are correct.
//
// Parameters:
//   l   I/P   int   The first dimension of A and C
//   m   I/P   int   The second dimension of A and first of B
//   n   I/P   int   The second dimension of B and C
//   A   I/P   float *   The first input matrix
//   B   I/P   float *   The second input matrix
//   C   O/P   float *   The output matrix
//   matmul   O/P   int   Status code
///////////////////////////////////////////////////////////////////////////////
int matmul( int l, int m, int n, float *restrict A, float *restrict B, float *restrict C )
{
   int i, j, k;

   for( i=0; i<l; i++ )               // Loop over the rows of A and C.
   for( k=0; k<n; k++ )               // Loop over the columns of B and C
   {
   // Initialize the output element for the inner
   // product of row i of A with column j of B
   C[i*n+k] = 0;                      
   for( j=0; j<m; j++ )               // Loop over the columns of A and C
   {
       C[i*n+k] += A[i*m+j] * B[j*n+k];   // Compute the inner product
   }
   }
}

In: Computer Science