Please code this in C
In this project, we shall simulate the operations of an ATM machine.
Suppose you’re in charge of this simulation and here is a scenario of what is required to do:
The customer will be assigned a random number for his/her balance.
First, the customer is prompted to enter his personal identification number pin (for this case study, we test only if this pin is formed by 4 digits! otherwise, a message like “Invalid PIN, try again . . .” will be displayed) and the user is re-prompted to enter the pin. The customer is given three chances to enter his pin. If he/she fails during the three trials you display a message like “Sorry you can’t continue, contact your bank for assistance!”
If the pin is correct (formed by 4 digits), then the system will ask the customer for the receipt ( 1 for YES and 2 for NO ) and a menu will be displayed containing five possible options to choose from: Fast Cash, Deposit, Withdraw, Balance and Get Card Back.
Here is the explanation of each of the 5 options:
Get Card Back: Display the message “Goodbye! “and exit the program.
Fast Cash: Let the customer choosing the amount of cash from a menu similar to the following:
Press:
1 --> $20.00 $40.00 <-- 2
3 --> $80.00 $100.00 <-- 4
Withdraw: Prompt the user for the amount of money he/she would like to withdraw and make the sure that he/she has enough money for that!
Deposit: Prompt the customer for the amount of deposit.
Balance: Just display the amount of money the customer has.
Don’t forget to print the receipt if the customer wants one.
Sample execution: bolded text represents the user entry
Virtual Bank at West
WELCOME
Enter Pin: 245
Invalid PIN, Re-enter Pin: 5487
(clear screen )
Receipt y or Y -> Yes No <- n or N
Enter choice: N
(Clear screen)
CHOOSE FROM THE FOLLOWING
1 -> Fast Cash Withdraw <- 2
3 -> Deposit Check Balance <- 4
5 -> Get Card Back
Enter your choice: 4
(Clear screen)
Your Balance is : $124.3
1 -> Another Transaction Get Card Back <- 2
Enter your choice: 1
(Clear screen)
CHOOSE FROM THE FOLLOWING
1 -> Fast Cash Withdraw <- 2
3 -> Deposit Check Balance <- 4
5 -> Get Card Back
Enter your choice: 2
(Clear screen )
Enter amount (enter 0 to cancel): 300.00
Sorry not enough balance
Enter amount (enter 0 to cancel): 30.00
Take your cash…
(Clear screen)
Your Balance is: $124.32
1 -> Another Transaction Get Card Back <- 2
Enter your choice: 1
(Clear screen)
CHOOSE FROM THE FOLLOWING
1 -> Fast Cash Withdraw <- 2
3 -> Deposit Check Balance <- 4
5 -> Get Card Back
Enter your choice: 8
Invalid Entry
(Clear screen)
CHOOSE FROM THE FOLLOWING
1 -> Fast Cash Withdraw <- 2
3 -> Deposit Check Balance <- 4
5 -> Get Card Back
Enter your choice: 5
(Clear screen)
THANK FOR USING OUR VIRTUAL BANK SYSTEM
GOODBYE. . .
In: Computer Science
Why is emergency management software so important? How important is software to emergency managers?
In: Computer Science
Write a program that creates three vector objects IN C++. Fill the first two objects with 25 floating-point numbers using a for loop as follows: 1. fill the first vector object with the loop counter value; 2. fill the second vector object with the loop counter value squared; 3. finally, write a for loop that adds the corresponding elements in the first two vectors, and puts the result in the corresponding element of the third vector. Display all three vectors using the format “for counter; element + element = element”.
In: Computer Science
Python Programming Question
1. Implement the median-of-three method for selecting a pivot value as a modification to quickSort (name this function
mo3_quickSort). Prepare test cases for your mo3_quickSort .function
QuickSort function:
def quickSort(alist):
quickSortHelper(alist,0,len(alist)-1)
def quickSortHelper(alist,first,last):
if first
splitpoint = partition(alist,first,last)
quickSortHelper(alist,first,splitpoint-1)
quickSortHelper(alist,splitpoint+1,last)
def partition(alist,first,last):
pivotvalue = alist[first]
leftmark = first+1
rightmark = last
done = False
while not done:
while leftmark <= rightmark and alist[leftmark] <=
pivotvalue:
leftmark = leftmark + 1
while alist[rightmark] >= pivotvalue and rightmark >=
leftmark:
rightmark = rightmark -1
if rightmark < leftmark:
done = True
else:
temp = alist[leftmark]
alist[leftmark] = alist[rightmark]
alist[rightmark] = temp
temp = alist[first]
alist[first] = alist[rightmark]
alist[rightmark] = temp
return rightmark
alist = [54,26,93,17,77,31,44,55,20]
quickSort(alist)
print(alist)
2. Prepare and run an experiment to verify the following hypothesis.
Canonic quickSort is as fast as mo3_quickSort when processing large lists of unsorted integers.
In: Computer Science
Terrain navigation is a key component in the design of unmanned aerial vehicles (UAVs). Vehichles such as a robot or a car, can travel on land; and vehiches such as a drone or a plane can fly above the land. A UAV system contains an on board computer that has stored the terrain information for the area in which it is to be operated, Because it knows where it is at all times (often using a global positioning system (GPS) receiver), the vehicle can then select the best path to get to a designed spot. If the destination changes, the vehicle can refer to its internal maps and recompute the new path. The computer software that guides these vechicles must be tested over a variety of land formations and topologies. Elevvation information for large grids of land is available in computer databases. One way of measuring the "difficulty" of a lanad grid with respect to terrain navigation is to determine the number of peaks in the grid, where a peak is a point that has lower elevations all around it. For this problem, we want to determine whether the value in grid position [m] [n] is peak. Assume that the values in the four positions shown are adjacent to grid position [m] [n]
| grid [m-1] [n] | ||
|---|---|---|
| grid [m][n-1] | grid [m][n] | grid [m][n+1] |
| grid [m+1] [n] |
Write a program in C PROGRAMMING that reads elevation data from a data file named grid1. txt. (this file you have to create and name it as grid 1.txt.) data as shown below which represent elevation for a grid that has 6 points along the side and seven points along the top ( the peaks have been highlighted and underlined):
5039 5127 5238 5259 5248 5310 5299
5150 5392 5410 5401 5352 5820 5321
5290 5560 5490 5421 5530 5831 5210
5110 5429 5430 5411 5459 5630 5319
4920 5129 4921 5821 4722 4921 5129
5023 5129 4822 4872 4794 4862 4245
Then prints the number of peaks and their locations. Assume that the first line of the data file contains the number of rows and the number of columns for the grid of information. These values are then followed by the elevation values, in row order. The maximum size of the grid is 25 rows by 25 columns.
Hints:
In: Computer Science
def sequentialSearch(theList, item):
#**** to be changed:
# counts the iterations of the while loop and
returns this value
found = False
index = 0
while index < len(theList) and not
found:
if theList[index] ==
item:
found = True
index = index +
1
return
found
def binarySearch(theList, item):
#**** to be changed:
# counts the iterations of the while loop and
returns this value
startIndex = 0
endIndex = len(theList)- 1
found = False
while startIndex <= endIndex and not
found:
middleIndex =
(startIndex + endIndex)//2
if item ==
theList[middleIndex]:
found = True
elif item >
theList[middleIndex]:
startIndex = middleIndex + 1
else:
endIndex = middleIndex - 1
return found
# program for testing the search algorithms
dataSet = [-200, -190, -180, -170, -160, -110, -105, -74, -30, -17,
-12, -1, 4, 5, 13, 26, 37, 42, 62, 96, 100, 110, 120,130]
print("\nSuccessful sequential search - all elements of the data
set")
totalComparisons = 0
#**** to be completed:
# list traversal on the dataSet list:
# for each item: perform a sequential
search and
#
display the number of comparisons,
# count the total number of
comparisons
print("Average number of comparisons:
"+str(totalComparisons/len(dataSet)))
print("\nUn-successful sequential search")
target =
196
# target not in the dataSet
comparisons = 0 #**** to be changed: perform a sequential search
for target
print ("target " + str(target), "\t comparisons used " +
str(comparisons))
print("\nSuccessful binary search - all elements of the data
set")
totalComparisons = 0
#**** to be completed:
# list traversal on the dataSet list:
# for each item: perform a binary search
and
#
display the number of comparisons,
# count the total number of
comparisons
print("Average number of comparisons:
"+str(totalComparisons/len(dataSet)))
print("\nUn-successful binary search")
target =
196
# target not in the dataSet
comparisons = 0 #**** to be changed: perform a binary search for
target
print ("target " + str(target), "\t comparisons used " +
str(comparisons))
make some change to the python according to the comment line and complete the following question.
|
Sequential Search Algorithm |
Binary Search Algorithm |
||
|
Successful searches |
Successful searches |
||
|
Average number of comparisons |
Average number of comparisons |
||
|
Maximum number of comparisons found at index _____________ |
Maximum number of comparisons found at index _____________ |
||
|
Minimum number of comparisons found at index____________ |
Minimum number of comparisons found at index____________ |
||
|
Un-Successful search |
Un-Successful search |
||
|
Number of comparisons |
Number of comparisons |
In: Computer Science
Do the type-D and JK flip flops respond to the same clock edge?
Explain how toggle mode is the same as division by two.
What is the difference between a synchronous input (D, J, or K) and an asynchronous input (PR or CLR)?
*please no handwritten answers
In: Computer Science
Table Product:
|
PROD_ID |
PROD_NAME |
PROD_PRICE |
PROD_VENDOR |
|
1101 |
Table |
100 |
2 |
|
1102 |
Chair |
80 |
3 |
|
1103 |
Armchair |
90 |
2 |
|
1104 |
Nightstand |
110 |
1 |
|
1105 |
Bed |
200 |
3 |
|
1106 |
Dresser |
150 |
3 |
|
1107 |
Daybed |
190 |
2 |
|
1108 |
Ash Table |
120 |
2 |
|
1109 |
Cherry Table |
130 |
2 |
|
1110 |
Table - High |
100 |
2 |
|
1111 |
Office Chair |
110 |
3 |
Table Vendor:
|
VEND_ID |
VEND_NAME |
VEND_ST |
|
1 |
Green Way Inc |
GA |
|
2 |
Forrest LLC |
NC |
|
3 |
AmeriMart |
NC |
Please write the SQL script and provide screenshots of results for these below queries. Please include the SQL in text format, and all screenshots in one single document.
In: Computer Science
Language: C++
In your main(), use printf() to print out the floating point values for
some hex data.
a. To print 1.0, do
printf("One: %f\n",0x3FF0000000000000);
The compiler will give you a warning about the argument being a different
type than the format, but that is ok.
b. To print 2.0, do
printf("Two: %f\n",0x4000000000000000);
Remember, to multiply by two, you just add one to the exponent.
c. Print 4.0, 8.0, and 16.0 (with nice labels, of course).
d. We can also go the other way. To divide by two, just decreas the
exponent by one. So for 1/2, do
printf("Half: %f\n",0x3FE0000000000000);
e. Print 1/4, 1/8, 1/16.
f. Negative values have a 1 in the leading bit instead of 0. A leading 1
in the bits for a hex digit has value 8, so -1.0 is BFF0000000000000.
So to print -1.0, do
printf("Neg One: %f\n",0xBFF0000000000000);
g. Print -2, -4, -8, -1/2, -1/4, -1/8 (with nice labels, of course).In: Computer Science
In a BestFriendSimulation driver class, define and initialize a
reference variable called myBestFriends referencing an ArrayList
ofBestFriend objects. Then, create a menu that will continue to
display itself, and process the requests of the user, until the
user requests to exit the menu (loop).
The menu should have 5 menu options:
1.) Add a BestFriend to the arrayList called myBestFriends; 2.) Change a BestFriend in the arrayList; 3.) Remove a BestFriend from the arrayList; 4.) Display all the objects in the myBestFriends arrayList. 5.) Exit
For each of these menu options, be sure to prompt the user for
the necessary information such as BestFriend's first name, last
name, nickname, and cell phone number.
Hint: In order to be able to change a BestFriend's information
or remove a BestFriend from the arrayList, you will have to create
a loop that will search the myBestFriends arrayList from beginning
to end, and store the index position of the BestFriend that will be
updated or removed. If the desired BestFriend is not found, a -1
will be returned from the search, or a not found flag will be set.
If the BestFriend is found, use that index position to either
change or remove that object from the myBestFriends
arrayList.
Make sure you test each of your menu options, and then select the
option that prints the table immediately afterwards, to ensure the
PhoneBook looks correctly.
1. Create the BestFriend Domain Class
Define and/or instantiate the private static and non-static
fields.
Create the constructor
public class BestFriend
{ private static int friendNumber = 0;
private int friendIdNumber;
private String firstName;
private String lastName;
private String nickName;
private String
cellPhoneNumber;
public BestFriend (String aFirstName, String aLastName, String aNickName, String aCellPhoneNumber)
{ firstName = aFirstName;
lastName = aLastName;
nickName = aNickName;
cellPhoneNumber
= aCellPhoneNumber;
friendNumber++;
friendIdNumber = friendNumber;
}
public String toString( )
{
return friendIdNumber + ". " + nickName + " " + firstName + " " + lastName + " " + cellPhoneNumber;
}
Create the set methods (setters)
Create the get methods (getters)
public boolean equals(Object another)
{
if (another instanceof BestFriend
)
{
BestFriend anotherBFF = (BestFriend)
another;
if
(firstName.equalsIgnoreCase(anotherBFF.firstName) &&
lastName.equalsIgnoreCase(anotherBFF.lastName)
// &&
nickname.equalsIgnoreCase(anotherBFF.nickName) &&
//
cellphone.equalsIgnoreCase(anotherBFF.cellPhone))
return true;
}
return false;
}
2. Create the BestFriendSimulation Driver
Class:
Instantiate an arrayList called
myBFFs
Create a Do …… While loop to create a menu of 5 choices
(add, change, remove, display, exit)
Allow the user to input the choice.
Use an if statement (or switch) to execute the user’s choice.
There are many ways to accomplish this task:
Technique #1.) Create a Helper class that defines the arrayList of BestFriends in its constructor, and then also defines the add, change, display, remove, and error methods as instance methods. Instantiate the Helper class from the driver (main) class. Also in the driver class, create the loop to display and process the menu options. When any specific menu option is selected, call the method from the Helper class.
Technique #2.) Instantiate the driver class in
the main method (instantiate its own self). Then, define
instance methods in the driver class for the add,
change, display, remove, and error methods. Call them from the menu
loop.
Technique #3.) In the driver class, create static
methods for the add, change, display, remove, and error methods.
Call them from the menu loop.
In any of the above 3 techniques, the arrayList of BestFriends can be defined as a global variable, so that it does not have to be passed as a parameter to each of the add, change, display, remove, and error methods. Similarly, the Scanner keyboard object should also be defined as a global variable too.
The alternative to defining the arrayList and Scanner keyboard as global variables is to pass these as parameters to each method call. For example:
addBFF(myBFFs, keyboard);
In: Computer Science
Intro to Python
1. Draw a structure chart for one of the solutions to the programming projects of Chapters 4 and 5. The program should include at least two function definitions other than the main function.
2.Describe the processes of top-down design and stepwise refinement. Where does the design start, and how does it proceed?
In: Computer Science
// C++ Doubly linked list
class clinknode{
friend class DList;
public:
clinknode(){next = prev=0;data =0;}
protected:
clinknode *next;
clinknode *prev;
int data;
}
class DList{
public:
DList(){first = last = 0;}
void insertFront(int key);
bool found(int key){ return search(key)!=0;}
void deleteAll(int key);
// other list functions...
private:
clinknode *search(int);
clinknode *first;
clinknode *last;
}
(20 points) Write the code for the deleteAll (int key) member function. It takes a key value and deletes all of the data in the list with that value. Make sure to preserve the integrity of the list. If no member with that value is in the list, this function should do nothing.
In: Computer Science
In: Computer Science
Use nested for loops to generate the following patterns: C++
*****
*****
*****
(no space between rows of asterisks)
*
**
***
****
*****
(Again, no empty lines between rows)
*
**
***
**
*
(no lines between rows)
Last one, let the user pick the pattern by specifying the number of rows and columns.
In: Computer Science
In C#, declare structure named Person. The structure should have the following attributes of first name, last name, zip code, and phone number.
In: Computer Science