Write a menu driven Java program which uses a method for each of the following operations:
(Note : The user should be allowed to repeat the operations as long as he wants to. Use appropriate number of parameters and return type for each method.)
A. to find the sum of the following series (up to N terms). The program should display the terms:
22 + 42 + 62…
For example, if N=4, then the program should display the following terms:
22 + 42 + 62 + 82
Sum of terms = 120
B. To accept a number and then check whether it is a prime number or a composite number. Your program should display an appropriate message. A prime number is one which is divisible by itself and 1.
Sample Outputs:
Enter a number : 5
It is a prime number.
Enter a number : 12
It is a composite number.
In: Computer Science
What are the strengths and weakness for Message Digest (MD5) and RIPEMD-128?
In: Computer Science
(My Name is TT please I need new and unique answers, please. (Use your own words, don't copy and paste), Please Use your keyboard (Don't use handwriting)
((Thank you FOR YOUR HELP))
SUBJECT: System analysis and design IT243
Q1:
As the project sponsor, you suggested that your company
that runs multiple local supermarkets should provide an online
shopping service to increase sales during COVID-19 pandemic. Write
a system request to propose this project.
System request
Project Sponsor
Business Need
Business Requirements
Business Value
Special Issues or Constraints
In: Computer Science
write a c++ code for following application You have been hired by XYZ Car Rental to develop a software system for their business. Your program will have two unordered lists, one of Cars and one of Reservations. The Car class will have the following data: string plateNumber (this is the key) string make string model enum vehicleType (VehicleType Enumeration of options: sedan, suv, exotic) double pricePerDay bool isAvailable isAvailable should be set to true on initialization, and a public setter method should be exposed SetAvailable(bool available); Reservation will have the following: string name (key) string vehicleRented (plate of the car which is our key for the list) The Program class will be composed of the two lists. There will also be a method to display a menu that will have the following options, Create a method to process the user's input and call appropriate methods to perform the operation requested. (Use a switch statement and call the appropriate methods based on the number the user puts in) ------------------------------------------- XYZ Car Rental ------------------------------------------- 1. List all cars 2. Add car to inventory 3. Remove car from inventory 4. List all reservations 5. Add a reservations 6. Cancel reservation 7. Exit Option 1: List all the cars in the unordered list of cars (Overload the << operator like my example to print each car's info) Option 2: Prompt for all the information for a vehicle. Create the vehicle and add it to the list of available vehicles Option 3: Remove a vehicle from the list of available cars. If the car is not available (a user has rented it) return an error message and don't remove the vehicle Option 4: List all the reservations. Use the key in the reservation to retrieve the vehicle details from the list of vehicles Option 5: Prompt the user for a name. List all the cars that are available (isAvailable=true): 1. Nissan Sentra (sedan) $24/day 2. ... n+1. Cancel Prompt the user to enter an option. Your list will need to implement a GetItemAtIndex method which will let you select a vehicle based on the menu option. For example if the user selects 1, you would call GetItemAtIndex(choice - 1). Make sure this returns a car reference: Car& GetItemAtIndex(int index) Create a reservation object with this car's plate and the user's name, and call the car's SetAvailable method with false passed as the argument; If cancel is pressed, show all the original options again Option 6: Propt the user for a name. Remove the reservation object from the list if that user's name is a key. Use the plate number to find the car in the list and set available to true (Make sure the GetItem method returns a reference) At the end of each option's method (except Exit) make sure ot list the menu options again. For Exit, quit the program.
In: Computer Science
Create a class named BankAccount, containing:
Write a class definition for a subclass, CheckingAccount, that contains:
In: Computer Science
1. Look at the following partial class definition, and then respond to the questions that follow it: public class Book { private String title; private String author; private String publisher; private int copiesSold; } a. Write a constructor for this class. The constructor should accept an argument for each of the fields. b. Write accessor and mutator methods for each of the fields. c. Draw a UML diagram for the class, including the methods you have written. 2. Consider the following class declaration: public class Addition { public int num1, num2; public String s1; public int add(int num1, int num2) { int sum = num1 +num2; return sum; } } a. Write a no argument constructor for the class. It should assign the value 0 to num1 and num2 fields. b. Write an overload constructor for this class that will concatenate the string values passed as arguments to it.
In: Computer Science
C programming in Shell
Implement a MS-DOS style pipe command. Make sure it allows for command-line arguments to be passed to the programs. You only need to support one pipe command at a time. For example, when you type ls | wc the shell should
In: Computer Science
. Describe the equipment (cable tester) needed and the steps to be followed to test the patch cable and the crossover cables to verify they have been properly assembled.
In: Computer Science
1. Design a class called BankAccount. The member
fields of the class are: Account Name, Account Number and Account
Balance. There are also other variables called MIN_BALANCE=9.99,
REWARDS_AMOUNT=1000.00, REWARDS_RATE=0.04. They look like
constants, but for now, they are variables of type double
Here is the UML for the class:
BankAccount
-string accountName // First and Last name of Account holder
-int accountNumber // integer
-double accountBalance // current balance amount
+
BankAccount()
//default constructor that sets name to “”, account number to 0 and
balance to 0
+BankAccount(string accountName, int accountNumber, double
accountBalance) // regular constructor
+getAccountBalance(): double // returns the balance
+getAccountName: string // returns name
+getAccountNumber: int
+setAccountBalance(double amount) : void
+withdraw(double amount) : bool //deducts from balance and returns
true if resulting balance is less than minimum balance
+deposit(double amount): void //adds amount to balance. If amount
is greater than rewards amount, calls
// addReward method
-addReward(double amount) void // adds rewards rate * amount to
balance
+toString(): String // return the account information
as a string with three lines. “Account Name: “ name
“Account Number:” number
“Account Balance:” balance
2. Create a file called BankAccount.cpp which implements the BankAccount class as given in the UML diagram above. The class will have member variables( attributes/data) and instance methods(behaviours/functions that initialize, access and process data)
3. Create a driver class to do the following:
a. Declare and instantiate a bank account called
accountZero using the default constructor
b. Declare and instantiate a bank account called
accountOne with name= “Matilda Patel” number =1232,
balance=-4.00
c. Declare and instantiate a bank account called
accountTwo with name = “Fernando Diaz”, number=1234,
balance=250
d. Declare and instantiate a bank account called
accountThree with name=”Howard Chen”, number=1236, balance =
194.56
e. Display the bank accounts in the three line format
as above
f. Deposit 999 dollars in Fernando’s account and
1000.25 in Howards account
g. Display their account information
h. Withdraw 10000 from Matildas account and 90 dollars
from Feranandos account
i. Display the results. If withdrawal is not possible
your program should say “Insufficient funds” otherwise it should
say “Remaining Balance :” balance amount
j. Print the total amount of all the bank accounts
created.
In: Computer Science
/**
* Returns the string formed by alternating the case of
the characters in
* the specified string. The first character in the
returned string is in
* lowercase, the second character is in uppercase, the
third character is
* in lowercase, the fourth character is in uppercase,
and so on.
* Examples:
*
* <ul>
*
<li><code>alternatingCaps("a")</code> returns
<code>"a"</code>
*
<li><code>alternatingCaps("ab")</code> returns
<code>"aB"</code>
*
<li><code>alternatingCaps("abc")</code> returns
<code>"aBc"</code>
*
<li><code>alternatingCaps("XYZ")</code> returns
<code>"xYz"</code>
*
<li><code>alternatingCaps("Toronto")</code>
returns <code>"tOrOnTo"</code>
*
<li><code>alternatingCaps("eecs2030")</code>
returns <code>"eEcS2030"</code>
* </ul>
*
* <p>
* The conversion of characters to lower or uppercase
is identical to
* that performed by the methods
<code>Character.toLowerCase(int)</code>
* and
<code>Character.toLowerCase(int)</code>
*
* @param s
*
a string
* @return the string formed by alternating the case of
the characters in s
*/
public static String alternatingCaps(String s) {
return "";
}
In: Computer Science
def mystery(L, x):
if L==[]:
return False
if L[0] == x:
return True
L.pop(0)
return mystery(L, x)
What is the input or length size of the function mystery?
What is the final output of mystery([1,3,5,7], 0)?
Explain in one sentence what mystery does?
What is the smallest input that mystery can have? Does the recursive call have smaller inputs? Why?
Assuming the recursive call in mystery is correct, use this assumption to explain in a few sentences why mystery is correct?
In: Computer Science
(My Name is AA please I need new and unique answers, please. (Use your own words, don't copy and paste),Please Use your keyboard (Don't use handwriting)
((Thank you FOR YOUR HELP))
SUBJECT: System analysis and design IT243
Q:1
There are three techniques which help users discover their needs for the new system, list and compare these techniques in terms of impactful changes. Also, explain BPR.
In: Computer Science
Single Lane Bridge Problem : Java Threads
Given :
//Use ReentrantLock for mutual exclusion
import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReentrantLock; public class bridge { private final ReentrantLock myLock = new ReentrantLock(); public bridge(){ } public String cross(){ myLock.lock(); try { return "crossing the bridge"; } finally { myLock.unlock(); } } }
public class lane extends Thread { int cars; bridge Bridge; public lane(int Cars1, bridge Bridge1) { cars = Cars1; Bridge = Bridge1; } public void run(){ for(int x=0;x
//Important clue :
<Thread-ID> waiting to cross
This means that this thread is now competing for the lock and will have to wait its turn.
- Once a thread has gained access to the critical section it should output:
<Thread-ID> crossing the bridge
- It takes different cars a different amount of time to cross the bridge, so your code should simulate this by sleeping for a random amount of time when accessing the critical section.
- Once a car has left the bridge, your program should output:
<Thread-ID> exiting
- Threads can enter the critical section in any order.
Create main such that the output is as follows :
Thread-0 waiting to cross
Thread-0 crossing the bridge
Thread-0 exiting
Thread-1 waiting to cross
Thread-2 waiting to cross
Thread-1 crossing the bridge
Thread-1 exiting
Thread-2 crossing the bridge
Thread-2 exiting
.....
.....
.....
.....
In: Computer Science
“Computer programming is creating a sequence of very precise instructions written in a language a computer understands, to perform a specified task with a computer.” Discuss in detail the concept of extreme precision in computer programming.
In: Computer Science
Left shift.
I am trying to left shift a string located in a text file. I am using c++ and the goal is to left shift by 1 character a string of length N, and output on stdout all of the performed shifts. Can someone tell me what I am doing wrong, and tell me what I can fix?
i.e: text file contains: Hi there!.
Output on stdout:
Hi there!, i there!H, _there!Hi, there!Hi_,...., !Hi_there. #here "_" represent space.
-------------------------------------------------------------------------------------------------------------------------
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <fstream>
using namespace std;
void shiftleft (vector <string> array, int d)
{
reverse(array.begin(), array.begin() + d);
reverse(array.begin() + d, array.end());
reverse(array.begin(), array.end());
}
int main()
{
string input_line;
vector<string> value;
ifstream file("LeftShift2.txt");
if(file.is_open())
{
while(getline(file, input_line))
{
value.push_back(input_line);
for(int i = 0; i < value.size(); i++)
{
cout << value[i] << "---->"<<endl;
shiftleft (value, 1);
}
}
}
}
--------------------------------------------------------------------------------
LeftShift2.txt
Hi there!
In: Computer Science