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 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 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
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 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 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
Please do in Java source
Social Security Payout. If you’re taking this course, chances are that you’re going to make a pretty good salary – especially 3 to 5 years after you graduate. When you look at your paycheck, one of the taxes you pay is called Social Security. In simplest terms, it’s a way to pay into a system and receive money back when you retire (and the longer you work and the higher your salary, the higher your monthly benefit). Interestingly, your employer will pay the same amount for you. The current tax rate is 6.2% until you make approximately $132,900. For this assignment, we’re going to help out hourly employees. Design (pseudocode) and implement (source code) a program that asks users how much they make per hour, the number of hours they work per week, and calculates the yearly income. For the second half, the program should calculate and display the amount of Social Security tax the user will pay for that year. You must write and use at least two functions in addition to the main function. At least one function must not have a void return type. Note, don’t forget to put the keywords “public” and “static” in front of your functions. Document your code and properly label the input prompt and the outputs as shown below.
Sample run 1: Enter hourly wage: 10
Enter your hours per week: 40
You will earn $20800.0 per year
You will pay $1289.6 in Social Security tax
Sample run 2: Enter hourly wage: 40
Enter your hours per week: 60
You will earn $124800.0 per year
You will pay $7737.6 in Social Security tax
In: Computer Science
In the game of Lucky Sevens, the player rolls a pair of dice. If the dots add up to 7, the player wins $4; otherwise, the player loses $1. Suppose that, to entice the gullible, a casino tells players that there are many ways to win: (1, 6), (2, 5), and soon. A little mathematical analysis reveals that there are not enough ways to win to make the game worthwhile; however, because many people's eyes glaze over at the first mention of mathematics “wins $4”.
Your challenge is to write a program that demonstrates the futility of playing the game. Your Python program should take as input the amount of money that the player wants to put into the pot, and play the game until the pot is empty.
The program should have at least TWO functions (Input validation and Sum of the dots of user’s two dice). Like the program 1, your code should be user-friendly and able to handle all possible user input. The game should be able to allow a user to ply as many times as she/he wants.
The program should print a table as following:
Number of rolls Win or Loss Current value of the pot
1 Put $10
2 Win $14
3 Loss $11
4
## Loss $0
You lost your money after ## rolls of play.
The maximum amount of money in the pot during the playing is $##.
Do you want to play again?
At that point the player’s pot is empty (the Current value of the pot is zero), the program should display the number of rolls it took to break the player, as well as maximum amount of money in the pot during the playing.
Again, add good comments to your program.
Test your program with $5, $10 and $20.
In: Computer Science
Write a C++ program that reads daily weather observation data from a file and writes monthly and annual summaries of the daily data to a file.
a. The daily weather data will be contained in a file named wx_data.txt, with each line of the file representing the weather data for a single day.
b. For each day, the date, precipitation amount, maximum temperature, and minimum temperature will be provided as tab-separated data with the following format: 20180101 0.02 37 23 20180102 0.00 42 18 <...data for the remainder of the year here...>
c. For the first entry in the daily data above, the date is 20180101 (1 January 2018), the precipitation amount is 0.02 inches, the maximum temperature is 37°F, and the minimum temperature is 23°F.
d. You may assume that the weather data is complete (i.e., there is data for each day of every month of the year) and that the data contains no errors.
2. The program must read from file each daily weather observation and write a summary by month and year to a file named wx_summary.txt.
a. The output that is written to file must have the following format:
-------------------
January
-------------------
Precipitation
Total: 3.12
Average: 0.10
Temperature
Maximum: 62
Minimum: 39
-------------------
February
-------------------
Precipitation
Total: 10.18
Average: 0.36
Temperature
Maximum: 78
Minimum: 64
-------------------
March
-------------------
Precipitation
Total: 2.02
Average: 0.07
Temperature
Maximum: 73
Minimum: 53
-------------------
April
-------------------
Precipitation
Total: 3.99
Average: 0.13
Temperature
Maximum: 77
Minimum: 58
-------------------
May
-------------------
Precipitation
Total: 3.73
Average: 0.12
Temperature
Maximum: 87
Minimum: 77
-------------------
June
-------------------
Precipitation
Total: 8.47
Average: 0.28
Temperature
Maximum: 92
Minimum: 75
-------------------
July
-------------------
Precipitation
Total: 6.79
Average: 0.22
Temperature
Maximum: 89
Minimum: 74
-------------------
August
-------------------
Precipitation
Total: 7.54
Average: 0.24
Temperature
Maximum: 82
Minimum: 74
-------------------
September
-------------------
Precipitation
Total: 18.25
Average: 0.61
Temperature
Maximum: 89
Minimum: 74
-------------------
October
-------------------
Precipitation
Total: 3.75
Average: 0.12
Temperature
Maximum: 82
Minimum: 72
-------------------
November
-------------------
Precipitation
Total: 5.62
Average: 0.19
Temperature
Maximum: 77
Minimum: 63
-------------------
December
-------------------
Precipitation
Total: 16.55
Average: 0.53
Temperature
Maximum: 72
Minimum: 67
-------------------
Max temp for year: 98 in May
Min temp for year: 21 in January
Max precip for year: 18.25 in September
In: Computer Science
Explain how to use a Scanner object to read
information from a page on the internet. Give an example.
Explain what a wrapper classes are and how they are used in
Java. Give an example.
What is an ArrayList object? How does is it
similar to and how does it differ from a traditional
array.
What is inheritance? How is it useful in software projects. How
is the is-a test related to inheritance?
What is an exception? Explain how to use try/catch blocks to
prevent a program from crashing.
What is refactoring? What are some of the ways that Eclipse can
help you with refactoring?
What is the output? Explain how you obtain this answer by hand, not using a computer.
String alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
for(int i = 1; i <= 26; i *= 2) {
System.out.print(alphabet.charAt(i - 1));
}
What is the output? Explain how you obtain this answer by hand, not using a computer.
int n = 500;
int count = 0;
while (n > 1) {
if (n % 2 == 0) {
n /= 3;
}
else {
n /= 2;
}
count++;
}
System.out.println(count);
A Java Swing application contains this paintComponent method for a panel. Sketch what is drawn by this method.
public void paintComponent(Graphics g) {
super.paintComponent(g);
g.setColor(Color.black);
g.fillRect(100, 100, 200, 100);
g.fillRect(300, 200, 200, 100);
g.fillRect(500, 100, 200, 100);
}
In: Computer Science
JAVA
Personal Information Class
Design a class that hold the personal data: name, address, age and phone number. Write appropriate methods (constructor, getters ad setters. Demonstrate the class by writing a program that creates three instances of the class. You can populate information in each object using Scanner class.
In: Computer Science
java - Write a method that sums all the numbers in the major diagonal in an n x n matrix of double values using the following header:
public static double sumMajorDiagonal(double [][]
m)
Write a test program that first prompts the user to enter the
dimension n of an n x n matrix, then asks them to enter the matrix
row by row (with the elements separated by spaces). The program
should then print out the sum of the major diagonal of the
matrix.
SAMPLE RUN:
Enter dimension n of nxn matrix:Enter row·0:Enter row 1:Enter·row 2:Enter row 3:17.1
(can have 3 or 4 rows)
In: Computer Science
Distinguish between tangible and intangible benefits.
In: Computer Science
Problem 3: The IsSorted class [30’]
Description:
This Java program will create an integer array object with arbitrary elements, and judge whether this array is sorted (non-decreasing). For example, array1 {2,3,1,0} is not sorted, while array2 {5, 8,10,12,15} is sorted.
You may assume the array is non-empty.
Specifications:
In addition to the main method, you need to create another method
main Method
isSorted Method
The isSorted() method takes in an array of integers as a parameter. It checks whether all elements in this array are sorted (arranged in non- decreasing order) or not, and return true or false.
Output
Your output should look something like follows:
//Suppose the array is [5, 0, 2, 3, 8]
$java IsSorted
The array is not sorted.
//Suppose the array is [1, 1]
$java IsSorted
The array is sorted.
//Suppose the array is [2, 6, 10, 15, 20]
$java IsSorted
The array is sorted.
//Suppose the array is [7, 4, 3, 0]
$java IsSorted
The array is not sorted.
In: Computer Science