in java
Create a class called Customer in three steps: • (Step-1): • Add a constructor of the class Customer that takes the name and purchase amount of the customer as inputs. • Write getter methods getName and getPrice to return the name and price of the customer. You can write a toString() method which returns printed string of Customer name and its purchase. • (Step-2): Create a class called Restaurant. • Write a method addsale that takes customer name and purchase amount of the customer in the class restaurant and stores it into an array list. • Write a method nameBestCustomer that returns customer name who bought highest sale in the restaurant. • (Step-3): Write a tester class that prompts the user to enter name and purchase of the customers and display the name of the customer who bought highest sales in the restaurant.
In: Computer Science
I need this code in java.
Task
(1) Create two files to submit:
Build the ItemToPurchase class with the following specifications:
(2) In main(), prompt the user for two items and create two
objects of the ItemToPurchase class. Before prompting for the
second item, call scnr.nextLine(); to allow the
user to input a new string. (2 pts)
Ex:
Item 1 Enter the item name: Chocolate Chips Enter the item price: 3 Enter the item quantity: 1 Item 2 Enter the item name: Bottled Water Enter the item price: 1 Enter the item quantity: 10
(3) Add the costs of the two items together and output the total
cost. (2 pts)
Ex:
TOTAL COST Chocolate Chips 1 @ $3 = $3 Bottled Water 10 @ $1 = $10 Total: $13
This is the given code so far:
import java.util.Scanner;
public class ShoppingCartPrinter {
public static void main(String[] args) {
Scanner scnr = new Scanner(System.in);
int i = 0;
String productName;
int productPrice = 0;
int productQuantity = 0;
int cartTotal = 0;
// TODO Create new item1 and new item2
// Prompt for item 1 details from user, create itemToPurchase
object
System.out.println("Item 1");
System.out.println("Enter the item name:");
productName = scnr.nextLine();
System.out.println("Enter the item price:");
productPrice = scnr.nextInt();
System.out.println("Enter the item quantity:");
productQuantity = scnr.nextInt();
System.out.println("");
// TODO: Set item1 fields here
// Promptr for item 2 details from user, create itemToPurchase
object
System.out.println("Item 2");
System.out.println("Enter the item name:");
scnr.nextLine(); // DO NOT OMIT THIS LINE
productName = scnr.nextLine();
System.out.println("Enter the item price:");
productPrice = scnr.nextInt();
System.out.println("Enter the item quantity:");
productQuantity = scnr.nextInt();
System.out.println("");
// TODO set item2 here
// Add costs of two items and print total
cartTotal = (item1.getPrice() * item1.getQuantity()) +
(item2.getPrice() * item2.getQuantity());
System.out.println("TOTAL COST");
System.out.println(item1.getName() + " " + item1.getQuantity()
+
" @ $" + item1.getPrice() + " = $" +
(item1.getPrice() * item1.getQuantity()));
System.out.println(item2.getName() + " " + item2.getQuantity()
+
" @ $" + item2.getPrice() + " = $" +
(item2.getPrice() * item2.getQuantity()));
System.out.println("");
System.out.println("Total: $" + cartTotal);
return;
}
}
In: Computer Science
in java
write a program that initializes a String variable with "Welcome to Jac444!". Then, use methods of the String class to examine the string and output a few properties of the string, namely The string by itself The length of the string The first character in the string The last character in the string The first word of the string The last word of the string Make sure that your output also contains how many words exists in the string.
In: Computer Science
In: Computer Science
COURSE : IT Enterprise systems
Consider the Relations below
STUDENT
Student# |
Std-Name |
Address |
1 |
Smith |
Jeddah |
2 |
Bob |
Buraidah |
3 |
Alice |
Dammam |
COURSE
Student# |
Course Code |
Course-Name |
1 |
IT241 |
Operating System |
2 |
IT210 |
Computer Network |
2 |
IT445 |
Decision Support System |
Write a query using the Right Outer Join to retrieve the record from the two relations. Also, construct the table displaying the output of your query.
note: NEED A UNIQUE ANSWER AND NO HANDWRITING PLEASE..
THANK YOU
In: Computer Science
import os def process_dir(p, indent): for item in os.listdir(path): if os.path.isfile("{0}/{1}".format(path, item)): print("\t"*indent, item) elif os.path.isdir("{0}/{1}".format(path, item)): print("\t"*indent, "\x1b[1;31m{}\x1b[0;0m".format(item)) process_dir("{0}/{1}".format(path, item), indent+1) else: print("Not a file or directory") path=input("Enter a valid system path: ") print("\x1b[1;31m{}\x1b[0;0m".format(path)) process_dir(path, 1)
In: Computer Science
In: Computer Science
Write a JAVA program that implements the following disk-scheduling algorithms:
In: Computer Science
2. Define the following terms in your own words :
a. Computer.
b. Hardware (H/W).
c. Software (S/W).
d. Input Devices.
e. Output devices.
f. Primary Memory.
g. Peripheral device.
In: Computer Science
COURSE : IT Enterprise systems
Consider the following enterprise scenario and answer the following questions. ABC is a wholesale company that sells electrical equipment and provides a website from which customers can inquiry about products and identify what they want to buy. When costumers order electrical equipment, they place their order on the ABC website. ABC does not own or hold any equipment as inventory. Rather, the ABC orders the equipment from the appropriate supplier and ranges for the equipment to be shipped directly from the supplier to the customers. The customers pay ABC and receive receipts. The ABC also pays the suppliers and keeps the excess as revenues.
note: NEED A UNIQUE ANSWER AND NO HANDWRITING PLEASE..
THANK YOU
In: Computer Science
Q1. The following is an X.509 certificate.
Certificate:
Data:
Version: 3 (0x2)
Serial Number:
3d:0e:98:b2:bf:af:fa:9e:99:91:05:64:69:6e:11:2a
Signature Algorithm: sha256WithRSAEncryption
Issuer: C=US, O=Symantec Corporation,
OU=Symantec Trust Network,
CN=Symantec Class 3 EV SSL CA - G3
Validity
Not Before: Aug 14 00:00:00 2017 GMT
Not After : Sep 13 23:59:59 2018 GMT
Subject: ... C=US/postalCode=22230, ST=Virginia,
L=Arlington/street=4201 Wilson Blvd,
O=National Science Foundation, OU=DIS,
CN=www.nsf.gov
Subject Public Key Info:
Public Key Algorithm: rsaEncryption
Public-Key: (2048 bit)
Modulus:
00:ca:fb:26:78:06:25:b1:9e:67:1d:69:0b:10:06:
cf:25:b6:7d:de:8e:56:80:e1:1c:38:52:62:43:fd:
...
Exponent: 65537 (0x10001)
Signature Algorithm: sha256WithRSAEncryption
4b:0d:62:11:b4:dc:78:09:12:c1:1b:24:ff:98:43:58:1c:54:
0a:34:be:8f:3f:12:8f:17:4a:fe:5b:26:13:1a:5f:a7:87:ad:
...
ba:2c:10:c7:bc:8b:2c:15:6e:0c:d2:d0:8b:74:52:c8:ed:05:
0b:9b:62:41
(a) Who issues the certificate?
(b) Who is the owner of the certificate?
(c) Who generated the signature on this certificate, and how can this signature be verified?
(d) The public key contained in this certificate is based on the RSA algorithm. Using the RSA algorithm, to encrypt a message M, we calculate Me mod n. What is the value of e and n in this public key? If a number is too large, you only need to write down its first four bytes.
(e) Before issuing the certificate, the CA needs to do a verification regarding the subject field. What is the main purpose of a certificate, i.e. why a subject needs a certificate? What has been the steps taken by the CA to verify the subject in this case?
In: Computer Science
For a mass storage device e.g. a hard disk or solid state disk give an example of data processing when:
In: Computer Science
6.23 LAB: Python insert/update sqlite3 datafiles
Given is a Python program that connects to a sqlite database and has one table called writers with two columnns:
The writers table originally has the following data:
name, num Jane Austen,6 Charles Dickens,20 Ernest Hemingway,9 Jack Kerouac,22 F. Scott Fitzgerald,8 Mary Shelley,7 Charlotte Bronte,5 Mark Twain,11 Agatha Christie,73 Ian Flemming,14 J.K. Rowling,14 Stephen King,54 Oscar Wilde,1
Update the Python program to ask the user if they want to update entries or add new entries. If the name entered already exists in the writers table then the database record is updated, overwriting the original contents. If the name does not exist in the writers table, then add a new record with the writer's name and number of works. The following TODO sections must be completed.
Ex: If the input is:
y J.K. Rowling 30 y Elton John y 62 n
The output is:
(ID, Name, Num) (1, 'Jane Austen', 6) (2, 'Charles Dickens', 20) (3, 'Ernest Hemingway', 9) (4, 'Jack Kerouac', 22) (5, 'F. Scott Fitzgerald', 8) (6, 'Mary Shelley', 7) (7, 'Charlotte Bronte', 5) (8, 'Mark Twain', 11) (9, 'Agatha Christie', 73) (10, 'Ian Flemming', 14) (11, 'J.K. Rowling', 30) (12, 'Stephen King', 54) (13, 'Oscar Wilde', 1) (14, 'Elton John', 62)
In: Computer Science
Based on your project scenario that has been suggested by you or by your instructor and approved by your instructor, answer the following questions.
Project Title:
Scenario Overview:
Q1
Q2
Using any project management tool,
In: Computer Science
Write the functions necessary to simulate a gambling game with the following rules:
The winner is the player who has a total closest to 9 without going over.
1. The player "rolls" 2 dice (6 sided dice)
2. The computer "rolls" 2 dice (6 sided dice)
3. The user is asked whether they want to roll one more time. If they indicate they do, another dice is rolled and added to the player's total.
4. A message is printed indicating the winner. In the case of a tie, the player wins. If both the computer and player go over 9, the computer wins.
5. YOU MAY ASSUME THAT THE USER ENTERS A VALID INTEGER (1 or 2) AS THEIR CHOICE.
You may NOT change the main function except to insert the if statement and print statements as indicated.
# define functions
def rollDice():
# function returns a random number between 1 and 6
def userWon(t1, t2):
# function accepts player total and computer total
# function returns true if player wins
# function returns false if computer wins
def main():
# each player rolls two Dice
player = rollDice() + rollDice()
computer = rollDice() + rollDice()
# ask the player if they want to roll again
again = int(input("Please enter 1 to roll again. Enter 2 to
hold."))
# roll again if needed and add to player's total
if again == 1:
player = player + rollDice()
# insert your if statement here to determine the
winner
# and your appropriate print statements
main()
In: Computer Science