Questions
Part 3 Write a C++ program that prompts the user for an Account Number(a whole number)....

Part 3

Write a C++ program that prompts the user for an Account Number(a whole number). It will then prompt the user for the initial account balance (a double). The user will then enter either w, d, or z to indicate the desire to withdraw an amount from the bank, deposit an amount or end the transactions for that account((accept either uppercase or lowercase). You must use a nested if statements instead of a Switch construct.

Test Run:

Enter the account number: 1

Enter the initial balance: 5000

SAVINGS ACCOUNT TRANSACTION

(W)ithdrawal

(D)eposit

(Z) to end account transaction

Enter first letter of transaction type (W, D or Z): w

Amount: $1000

Balance for this account is now: $4000.00

SAVINGS ACCOUNT TRANSACTION

(W)ithdrawal

(D)eposit

(Z) to end account transaction

Enter first letter of transaction type (W, D or Z): d

Amount: $500

Balance for this account is now: $4500.00

SAVINGS ACCOUNT TRANSACTION

(W)ithdrawal

(D)eposit

(Z) to end account transaction

Enter first letter of transaction type (W, D or Z): z

No more changes.

Balance for this account is now: $4500.00

Press any key to continue . . .

In: Computer Science

Write a program that uses a structure to store the following data on a company division...

Write a program that uses a structure to store the following data on a company division in c++

  • Division Name (such as East, West, North, or South)
  • First-Quarter Sales
  • Second-Quarter Sales
  • Third-Quarter Sales
  • Fourth-Quarter Sales
  • Total Annual Sales
  • Average Quarterly Sales

The program should use four variables of this structure. Each variable should represent one of the following corporate divisions: East, West, North, and South. The user should be asked for the four quarters’ sales figures for each division. Each division’s total and average sales should be calculated and stored in the appropriate member of each structure variable. These figures should then be displayed on the screen.

Input Validation: Do not accept negative numbers for any sales figures.

In: Computer Science

For this question, you need to implement Java code for the following Modified Ciphertext encryption and...

For this question, you need to implement Java code for the following Modified Ciphertext encryption and attack for known patterns to find the code.

Please read the modified Ciphertext carefully and examples before implementing them.  

Modified Ciphertext is working as follows:

If a plain text (only letters ignore uppercase or lowercase) and sequences of numbers are given, it encrypts the given plain text by shifting each letter in a message the characters based on the given numbers one forward direction and one backward direction in order.

Example: consider the repeating key: 3 1 7 4 2 5 6, and plain text is "Hello World"

The encoded message will be: "Kdshq Ruomw"

H->3 = K, e<-1= d, l->7 = s, l<-4 = h, o->2 = q, W<-5 = R, o->6 = u, r<-3 = o, l->1 = m, d<-7 = w.

First, implement an encryption method:

"String encryption(String message, String code)" method that returns the encoded message according to the given message and code.

Ex: encryption( "Hello World", "3174256 ") will return "Kdshq Ruomw"

Second, implement an attack method:

"String attack(String message, String encoded_message)" method that returns the predicted code without knowing back or forward movements.

You may assume that every digit in the code is distinct.

Ex: attach( "Hello World", " Kdshq Ruomw") will return "3174256"


Please submit a Java code for two methods and JUnit tests that show both methods work for different cases, including exception cases such as non-digit for code or non-plain text.

In: Computer Science

You are required to solve the problem on Terrain Navigatio. Terrain navigation is a key component...

You are required to solve the problem on Terrain Navigatio.

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 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:

  1. Define and print the number of peaks and their locations in an elevation grid.
  2. input is a file containing the elevation data and the output is a listing of the location of the peaks.
  3. to specify the location of the peaks, you need to assign an addressing scheme to the data because you are going to implement this solution in c. Therefore, choose its 2D array subscripting notation.
  4. assume the top left corner is position [0][0], the row numbers increase by 1 as move down the page and the column numbers increase by 1 as move to the right.
  5. These peaks then occur at position[2][1], [2][5], and [4][3].
  6. To determine the peaks, compare a potential peak with its four neighbouring points.
  7. if all four neighboring points are less that the potential peak, then the potential peak is a real peak.
  8. the points on the edges of the array or grid cannot be potential peaks because do not have elevation information on all four sides of the points.

please help to answer all

need type answer in c language

In: Computer Science

Write a Java Program to determine if a candidate qualifies for a FHA Mortgage. The qualifications...

Write a Java Program to determine if a candidate qualifies for a FHA Mortgage.

The qualifications given are:
  • Residence: The home must be your primary residence.
  • Down payment: They must have a credit score of at least 563.
The Java Program needs to do the following. This can all be done in the main()  method.
  1. Create a boolean variable to store the Residence requirement.
  2. Prompt the user to "Enter 1 if the Home will be the primary residence, or 0 if not the primary residence". Store the result of step 2 into a byte variable.
  3. Set the boolean variable from step 1 to true or false depending on value in step 2.
  4. Create an int variable to store the credit score.
  5. Prompt for the credit score and store it in the variable created in step 5.
  6. If the residency and credit score qualify, then display "Qualifies for the loan". Otherwise display "Does not qualify for the loan".

This can all be done inside the main() method.

Example Input/Output:

Enter 1 if the Home will be the primary residence, or 0 if not the primary residence: 1

Enter the Credit Score: 500

Does not qualify for the loan.

In: Computer Science

discuss how using VirtualBox and the Linux LAMP server represents cloud computing. And, discuss what a...

discuss how using VirtualBox and the Linux LAMP server represents cloud computing. And, discuss what a cloud consumer needs to know about how virtualization and cloud computing creates value for a business. In addition, for the second part of the discussion, make sure you mention virtualization security.

In: Computer Science

Write the program in Java (with a graphical user interface) and have it calculate and display...

Write the program in Java (with a graphical user interface) and have it calculate and display the mortgage payment amount from user input of the amount of the mortgage, the term of the mortgage, and the interest rate of the mortgage. Allow the user to loop back and enter new data or quit. You need to include Calculate, Reset, and Exit buttons on your GUI. Please insert comments in the program to document the program. Allow the user to enter the values of the loan, term, and rate. Do not add any additional touches, keep it simple.

In: Computer Science

In Java write an application that calculates total retail values for 5 different shoes entered by...

In Java write an application that calculates total retail values for 5 different shoes entered by the user.

Shoe 1 $15.50
Shoe 2 $27.30
Shoe 3 $34.50
Shoe 4 $42.11
Shoe 5 $54.25

Application must read shoe number and quantity sold for each product stdin, compute the total value of that sale, and add the value of that sale to a grand total for that shoe. After all data has been entered, display the total value of each of the five shoe items. Must have two classes, must use a switch structure to which shoes sales to update, must use a sentinel controlled loop to determine when the program should stop looping and display result.

Methods
One 1 argument constructor, getters and setters for each field, and updateTotalSales method(uses one parameter representing quantity sold and does not return a value) . must use getter and setter methods t access the fields do not access them directly.

Sample run
Shoe number: 2
Quantity sold: 4
Shoe number: 1
Quantity sold: 3
Shoe Number: 5
Quantity sold: 2
Shoe number: 1
Quantity sold: 2
Shoe number: 5
Quantity sold: 3
Shoe Number: 4
Quantity sold: 2
Shoe Number: 0

Total Sales
Shoe 1 : $31.00
Shoe 2: $109.20
Shoe 3: $0
Shoe 4: $84.22
Shoe 5: $271.25

In: Computer Science

Determine the output of the following pseudo-code. Also, explain how did you get this output. fun(int...

Determine the output of the following pseudo-code. Also, explain how did you get this output.

fun(int n){
   if (n==1) then return;
   println(n);
   if (n%2=0) then
     fun(n/2);
   else
     fun(3*n + 1);
}
Main(){
  fun(14);
}

In: Computer Science

1)How has the ability to visualize the vast amount of data on the internet changed the...

1)How has the ability to visualize the vast amount of data on the internet changed the face of ecommerce in the last 5 years?
2)How do you think it will transform business in the next 5 years?

In: Computer Science

Solve the following linear programming problem using both geometric method and simplex: MIN  12X1 + 16X2 S.T.     X1...

Solve the following linear programming problem using both geometric method and simplex:

MIN  12X1 + 16X2

S.T.     X1 +   2X2          >= 40  

                     X1 +    X2>= 30     

      

                        X1, X2>= 0,

In: Computer Science

What are the parts of a routine request and the best practices for explaining and justifying...

What are the parts of a routine request and the best practices for explaining and justifying a routine request?

In: Computer Science

Answer ONLY in C language. Server program: The server program provides a search to check for...

Answer ONLY in C language.

Server program:

The server program provides a search to check for a specific value in an integer array. The client writes a struct containing 3 elements: an integer value to search for, the size of an integer array which is 10 or less, and an integer array to the server through a FIFO. The server reads the struct from the FIFO and checks the array for the search value. If the search value appears in the array, the server indicates the index of the first occurrence of that value in the array. The server writes back to the client a struct that contains the search value and its array position. If the value does not occur in the array, the search value and an appropriate return code are returned to the client. (An appropriate return code for not finding the search value could be -1)

The server program needs to:

  • Create a well-known FIFO, named FIFO_to_Server through which the server reads a struct from the client
  • Open FIFO_to_Server in READ mode
  • Read a request from a client that includes a struct containing a search value, the size of the integer array and the array itself, all integers.
  • Find the index (start counting with zero) of the search value, if one exists
  • Create a FIFO named FIFO_to_Client through which the server responds to the client
  • Open FIFO_to_Client in WRITE mode
  • Write the search value and the index position back to the client through FIFO_to_Client
  • Close FIFO_to_Client
  • Unlink FIFO_to_Client
  • Close FIFO_to_Server
  • Unlink FIFO_to_Server

Client Program:

The client program requests an integer value to search for,  an array size and array elements to fill the array. The client program should:

  • Open FIFO_to_Server in WRITE mode
  • Prompt the user for a search value
  • Prompt the user for an array size
  • Prompt the user for elements to fill that array
  • Write the struct that includes the search value, the array size and the array to FIFO_to_Server
  • Close FIFO_to_Server *
  • Open the FIFO_to_Client in READ mode
  • Read the response from the server from FIFO_to_Client
  • Print a message such as “The value 87 occurs in array position 4”
  • Close FIFO_to Client

In: Computer Science

You has been requested to design and develop a food ordering system based on following requirements:...

You has been requested to design and develop a food ordering system based on following requirements:

The system shall allow the user to place an order for the food(s), view the food details, modify or delete the details of the food if necessary. Your program should be menu driven, giving the user various choices. You shall design the system by demonstrating the full understanding of object-oriented and use of list/link-list concept.

For every food order, the following information will be stored: Order ID (Auto assigned, unique ID), Food Code, flavor (example: Strawberry, chocolate), weight (Kg), Unit Price, Qty and customer information who order this cake. The customer information consists of customer ID, name, address and contact number. The order ID shall be automatically assigned with a unique ID when new order is added. The system shall display additional information that is amount (unit price * qty) when viewing the order details.

*in C++ language .

Functionalities provided:

Please select an action
[1] Place Order
[2] View Food Details
[3] Modify Food Details
[4] Delete Food
[5] View All Orders
[6] Delete Order
[7] Display Customer Details
[8] Add Food
[9] Exit

In: Computer Science

Complete the code. You are given a zip file that contains an online multiplayer Tic-tac-toe system....

Complete the code. You are given a zip file that contains an online multiplayer Tic-tac-toe system. The system comprises two main modules: Server and Client and uses server – client communication between them. You will have to extend the client and server files to include the missing communications using socket programming. In this game, the server runs indefinitely, waiting for a client. A client connects to the server to see if there are other players online. A client then invites one of the players to play the game. If the asked player accepts the invitation, the game will start. At the end of the game, the two players can either play again or quit the game and return to the server command line. The Tic-tac-toe Client: In the beginning, the client will prompt the player to specify the server IP address. The client will then list all the commands supported by the client. There are four commands included in the client implementation: join, list, invite and leave. The client creates two different threads to handle the connection with the server and the opponent client. Client commands: join: followed by a username that the player wishes to use in the game. list: list the usernames of all online players. invite: send a play request to another player. leave: leave the game; this will remove the player name from the online player list. The Tic-tac-toe Server: The server maintains clients' information in a hash-map data structure where the client IP address and username are used as a key; this allows multiple clients with a different IP address to use the same username. The server uses a multi-threaded approach to concurrent server design: for each client, a new thread is created to handle the client request. This thread will exit when the client sends a leave command to the server.

Fill in the coed that is numbered

SERVER.C

#include <stdlib.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#include <pthread.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include "uthash.h"/*Create and maintain HashMap functions*/

#define QLEN 15 /* max number of pending incoming connections */
#define BUFFERSIZE 1500 /* max size of buffer*/
#define STRLEN 100 /* max string length */

typedef struct {
char name [STRLEN];
char ip_addr [STRLEN];
} record_key_t;

typedef struct {
record_key_t key;
int status;
UT_hash_handle hh;
} record_t;

/* functions prototype*/

void * server_thd(void * parm);       /* a function to handle communication with clients */

void get_online_Players(const void *key, const void *value, void *obj); /* a function to handle the li$

int add_user(char name [STRLEN], char ip_addr [STRLEN]);

void print_users();

void user_left(char name [STRLEN], char ip_addr [STRLEN]);

void user_join(record_t *p);

record_t *users = NULL; /* init. hashmap list*/

pthread_mutex_t mut; /* Mutex to prevent multiple write. */

int size = 0;

int main () /* the main function*/

{

    struct   sockaddr_in sarver_ad;      /* to store server local ip and port */

    struct   sockaddr_in client_ad;      /* to store client ip and port */

    int      server_fd, client_fd;                    /* socket descriptors */

    int      port = 9090;                /* protocol port number */

    int      addr_len;                       /* length of address */

    pthread_t thrd_id;                      /* variable to hold thread ID */

    pthread_mutex_init(&mut, NULL);

    bzero( &sarver_ad, sizeof(sarver_ad));      /* clear sockaddr struct.*/

    /* 1) here you need to set up the sockaddr_in*/

    /* set address family */

   

    /* set the local IP address to any local address */

    /* set the local port to 9090 */

    /* Create a socket */

    /* 2) here you need to create a socket*/

    /* 3) here you need to create a socket Bind a local address to the socket */

    /* 4) here you need to make the server listen on server_fd for incoming connections */

    /* Main server loop - accept and handle requests */

    fprintf(stderr, "Server up and running.\n");

    while (1) {

        /* 5) here you need to make accept incoming connections before the new thread is created*/

        /* Create seperate thread for each client */

        pthread_create(&thrd_id, NULL, server_thd, (void *) client_fd );

    }

close(server_fd); /* Close socket */

}

int add_user(char name [STRLEN], char ip_addr [STRLEN])

CLIENT.C

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <arpa/inet.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <sys/socket.h>
#include <stdbool.h>
#include <pthread.h>

#define MAXBUFFER 100 /*Maximum buffer size*/
#define MAXSTRINGLEN 100 /*Maximum String length*/

#define SERVERPORTNUM 9090 /*server port number*/

#define HOSTPORTNUM 12345 /* Local port number */
#define PEERPORTNUM 12345 /* peer port number */

char name[MAXSTRINGLEN], /* name used to join the server */
peer_name[MAXSTRINGLEN];/* name of opponent */
pthread_t thrid_id; /*thread Id*/

int current_player=0; /* local user score*/
int other_player=0; /* remote user score*/


void tic_tac_toe(int socket, char * buffer, int playerID); /*the tic tac toe game.*/
void * serverConn(void * parm); /* Thread function to handle communication with the server */
void * peerConn(char * ip); /* Thread function used when we want to open a connection with$
void print_instraction(); /* to print the game instructions */

int server_socket, peer_socket, listn_socket, consocket; /* All socket descriptors are stored as globa$
int ingame, turn; /* Some variables to handle the flow of the game. */

int main(int argc, char *argv[])
{
printf("Enter Server's IP: ");
const char server[30]; /* store IP address of server */
scanf("%s",server);

/* Establish connection with the server */
struct sockaddr_in dest;
/* 1) here you need to create a socket named 'server_socket' to connect to the server */

memset(&dest, 0, sizeof(dest));
/* 2) here you need to creat sockaddr_in to store server info.*/


/*connect to the server*/
/* 3) here you need to 'server_socket' to the server.*/

pthread_create(&thrid_id, NULL, serverConn, (void*) &server_socket);

/* For Invitation */
/* Bind to a socket and start listening for incomming connections. peer-to-peer*/
struct sockaddr_in peer;
struct sockaddr_in serv;
socklen_t socksize = sizeof(struct sockaddr_in);
memset(&serv, 0, sizeof(serv));
/* 4) here you need to set up the sockaddr_in*/
/* 5) here you need to create a socket*/
/* 6) here you need to create a socket Bind a local address to the socket */
/* 7) here you need to make the server listen on server_fd for incoming connections, Only accept o$
/* 8) here you need to make accept incoming connections before the new thread is created*/

char buffer[MAXBUFFER]; /* Buffer to hold data exchanged */
int len;

/* handle peer connection request */
while(consocket)
{
pthread_cancel(thrid_id);
/* Receive peer's name and store it as current opponent */
len = recv(consocket, buffer, MAXBUFFER, 0);
buffer[len] = '\0';
strcpy(&peer_name, buffer);
printf("\n%s has challenged you. Accept challenge? (y/n) ", peer_name);

/* Ask for approval */
fgets(buffer, sizeof(buffer), stdin);
buffer[strlen(buffer)-1] = '\0';
if (strcmp(buffer, "y") == 0)
{
current_player=0;
other_player=0;
printf("\nYour Score: %d", current_player);
printf("\nOpponent's Score: %d",other_player);
ingame = 1;
send(consocket, buffer, strlen(buffer), 0);
}
else

{
current_player=0;
other_player=0;
send(consocket, buffer, strlen(buffer), 0);
printf("\nYou declined...\n");
ingame = 0;
}

/* Play game until one of the player declines. */
turn = 0;
int playerID = 2;

/* Close all sockets before the program exits */
close(listn_socket);
close(consocket);
close(peer_socket);
close(server_socket);

return EXIT_SUCCESS;
}


  

In: Computer Science