Three employees in a company are up for a special pay increase. You are given a file, say Ch3_Ex5Data.txt, with the following data: Miller Andrew 65789.87 5 Green Sheila 75892.56 6 Sethi Amit 74900.50 6.1 Each input line consists of an employee’s last name, first name, current salary, and percent pay increase. For example, in the first input line, the last name of the employee is Miller, the first name is Andrew, the current salary is 65789.87, and the pay increase is 5%. Instructions Write a program that reads data from a file specified by the user and stores the output in the file Ch3_Ex5Output.dat. For each employee, the data must be output in the following form: firstName lastName updatedSalary. Format the output of decimal numbers to two decimal places.
Please paste the source code in C++
In: Computer Science
PHTHON 3
Write code that generates a list of the names of all the senders of the messages in fb_data. Store it in a variable called senders.
fb_data = {
"data": [
{
"id": "2253324325325123432madeup",
"from": {
"id": "23243152523425madeup",
"name": "Jane Smith"
},
"to": {
"data": [
{
"name": "Your Facebook Group",
"id": "432542543635453245madeup"
}
]
},
"message": "Understand. Extract. Repeat.",
"type": "status",
"created_time": "2014-10-03T02:07:19+0000",
"updated_time": "2014-10-03T02:07:19+0000"
},
{
"id": "2359739457974250975madeup",
"from": {
"id": "4363684063madeup",
"name": "John Smythe"
},
"to": {
"data": [
{
"name": "Your Facebook Group",
"id": "432542543635453245madeup"
}
]
},
"message": "Here is a fun link about programming",
"type": "status",
"created_time": "2014-10-02T20:12:28+0000",
"updated_time": "2014-10-02T20:12:28+0000"
}]
}
In: Computer Science
Write a Python program that asks the user to enter a student's name and 8 numeric tests scores (out of 100 for each test). The name will be a local variable. The program should display a letter grade for each score, and the average test score, along with the student's name. Write the following functions in the program: calc_average - this function should accept 8 test scores as arguments and return the average of the scores per student
determine_grade - This function should accept a test score average as an argument and return a letter grade for the score based on the following grading scale: 90-100 A 80-89 B 70-79 C 60-69 D Below 60 F
REMEMBER - to put your name on the lab in comments and put comments in your program for what the program is doing.
Don't forget the comments.
In: Computer Science
Complete the following Customer class below. Also, add the equals method that would compare each field.
Please pay attention to the format of the equals method as it needs to have the same format as shown below.
public class Customer {
private int id; //customer id
private String name; //customer's name
private int discount; //discount rate in percent
//construct a new customer
public Customer(int id, String name, int discount) {
}
//returns the field values
public int getId () {
}
public String name () {
}
public int discount () {
}
//returns String for customer. Eg: "Mary, id:1111, discount 10%"
public String toString () {
}
public boolean equals (Object other) {
if (other instanceof some_class) {
//do casting
return logical_statement_for_comparison;
} else {
return false;
}
}
In: Computer Science
2. Report Heading Design a class called Heading that has data members to hold the company name and the report name. A two-parameter default constructor should allow these to be specified at the time a new Heading object is created. If the user creates a Heading object without passing any arguments, “ABC Industries” should be used as a default value for the company name and “Report” should be used as a default for the report name. The class should have member functions to print a heading in either one-line format, as shown here: Pet Pals Payroll Report or in four-line “boxed” format, as shown here: ******************************************************** Pet Pals Payroll Report ******************************************************** Try to figure out a way to center the headings on the screen, based on their lengths. Demonstrate the class by writing a simple program that uses it.
In: Computer Science
In Python Create customer information system as follows:
Ask the user to enter name, phonenumber, email. Create a file by his name and save it in the hard disk. Do this repeatedly until all the users are entered. (for example, if the user enters 10 customers’s information, there should be 10 different files created.)
Now build the customer value for a retail company as follows:
Ask the customer to enter his name. If you have his information already stored, then showing him his stored number and email. If not, ask his phone and email and save on his name.
Ask him to enter what he buying (itemname, quantity, unit price.) repeatedly until he enters all the items. Calculate the total including the tax (0.0825). Append the total price to his file.
In: Computer Science
1. On an index card or piece of notebook paper, draw a structure (see #3 below)
2. For the structure you draw, indicate how many total peaks it would have in its regular 13C NMR spectrum, how many DEPT 90 peaks, how many negative peaks in the DEPT 135, and finally how many positive peaks in DEPT 135.
3. Please use the following parameters for your structure:
LAST NAME A-C: a compound with 8 carbons or less that does NOT include a ring
LAST NAME D-H: a compound with between 9 and 12 carbons that includes a ring
LAST NAME L-Sal: a compound with 8 carbons or less that includes a ring
LAST NAME Set-W: a compound with between 9 and 12 carbons that does NOT include a ring
In: Chemistry
Write program#1 upload .java file.
#1 Write a java program that prompts the user for input using the Scanner class.
<END>
In: Computer Science
Assignment
Implement Conway’s Game of Life.
The Game of Life is a simple simulation that takes place in a grid of cells. Each cell can be either alive or dead, and it interacts with its neighbors (horizontally, vertically, or diagonally). In each iteration, a decision will be made to see if living cells stay alive, or if dead cells become alive. The algorithm is as follows:
If a cell is alive:
If it has less than two living neighbors, it dies due to loneliness.
If it has two or three living neighbors, it lives to the next generation
If it has more than three living neighbors, it dies due to overpopulation.
If a cell is dead:
and, if it has exactly three live neighbors, it becomes alive due to reproduction.
After each simulation round, your program must print the updated game board to screen.
Functional Requirements
Nonfunctional Requirements
Hint
When doing a simulation run, define a second two-dimensional array. For each cell in the existing array, count the number of neighbors it has, and decide what its fate will be on the new board. After having done this for all cells, copy the value of your new board over the old one
life.h
/* * life.h * * Created on: Sep 13, 2016 * Author: leune */ #ifndef LIFE_H_ #define LIFE_H_ #define XSIZE 15 #define YSIZE 15 #define DEFAULTROUNDS 15 #define ALIVE 1 #define DEAD 0 // initialize the board to all dead cells void initBoard(int vBoard[][YSIZE]); // play a round; updates the cells on the board void playRound(int vBoard[][YSIZE]); // print the board void printBoard(int vBoard[][YSIZE]); // determine the number of neighbors int neighbors(int vBoard[][YSIZE], int x, int y); /* determine if the given coordinates are within bounds * returns 0 if the cell is out of bounds; returns 1 if * the cell is in bounds */ int onBoard(int x, int y); #endif /* LIFE_H_ */
life.c
/*
* life.c
*
* Created on: Sep 13, 2016
* Author: leune
*/
#include <stdio.h>
#include <unistd.h>
#include "life.h"
int main(int argc, char *argv[]) {
int board[XSIZE][YSIZE];
int rounds = DEFAULTROUNDS;
initBoard(board);
board[5][5] = ALIVE;
board[5][6] = ALIVE;
board[5][7] = ALIVE;
board[6][6] = ALIVE;
printf("Playing %d rounds.\n\n", rounds);
for (int i=0; i<rounds; i++) {
printf("Round: %d\n", i+1);
printBoard(board);
playRound(board);
sleep(1);
}
return 0;
}
void initBoard(int vBoard[][YSIZE]) {
/* write this function */
}
void playRound(int vBoard[][YSIZE]) {
int tmpBoard[XSIZE][YSIZE];
initBoard(tmpBoard);
// perform the algorithm on vBoard, but update tmpBoard
// with the new state
/* write this fragment */
// copy tmpBoard over vBoard
for (int y=0; y < YSIZE; y++) {
for (int x=0; x < XSIZE; x++) {
vBoard[x][y] = tmpBoard[x][y];
}
}
}
int onBoard(int x, int y) {
if (x < 0 || x >= XSIZE)
return 0;
else
if (y < 0 || y >= YSIZE) return 0;
else
return 1;
}
int neighbors(int vBoard[][YSIZE], int x, int y) {
int n=0;
int xp1 = x + 1;
int xm1 = x - 1;
int yp1 = y + 1;
int ym1 = y - 1;
if (onBoard(xm1, y) && vBoard[xm1][y] == ALIVE) n++;
if (onBoard(xm1, yp1) && vBoard[xm1][yp1] == ALIVE) n++;
if (onBoard(x, yp1) && vBoard[x][yp1] == ALIVE) n++;
if (onBoard(xp1, yp1) && vBoard[xp1][yp1] == ALIVE) n++;
if (onBoard(xp1, y) && vBoard[xp1][y] == ALIVE) n++;
if (onBoard(xp1, ym1) && vBoard[xp1][ym1] == ALIVE) n++;
if (onBoard(x, ym1) && vBoard[x][ym1] == ALIVE) n++;
if (onBoard(xm1, ym1) && vBoard[xm1][ym1] == ALIVE) n++;
return n;
}
void printBoard(int vBoard[XSIZE][YSIZE]) {
/* write this fragment */
}In: Computer Science
Assignment
Implement Conway’s Game of Life IN C
The Game of Life is a simple simulation that takes place in a grid of cells. Each cell can be either alive or dead, and it interacts with its neighbors (horizontally, vertically, or diagonally). In each iteration, a decision will be made to see if living cells stay alive, or if dead cells become alive. The algorithm is as follows:
If a cell is alive:
If it has less than two living neighbors, it dies due to loneliness.
If it has two or three living neighbors, it lives to the next generation
If it has more than three living neighbors, it dies due to overpopulation.
If a cell is dead:
and, if it has exactly three live neighbors, it becomes alive due to reproduction.
After each simulation round, your program must print the updated game board to screen.
Functional Requirements
Nonfunctional Requirements
Hint
When doing a simulation run, define a second two-dimensional array. For each cell in the existing array, count the number of neighbors it has, and decide what its fate will be on the new board. After having done this for all cells, copy the value of your new board over the old one
life.h
/* * life.h * * Created on: Sep 13, 2016 * Author: leune */ #ifndef LIFE_H_ #define LIFE_H_ #define XSIZE 15 #define YSIZE 15 #define DEFAULTROUNDS 15 #define ALIVE 1 #define DEAD 0 // initialize the board to all dead cells void initBoard(int vBoard[][YSIZE]); // play a round; updates the cells on the board void playRound(int vBoard[][YSIZE]); // print the board void printBoard(int vBoard[][YSIZE]); // determine the number of neighbors int neighbors(int vBoard[][YSIZE], int x, int y); /* determine if the given coordinates are within bounds * returns 0 if the cell is out of bounds; returns 1 if * the cell is in bounds */ int onBoard(int x, int y); #endif /* LIFE_H_ */
life.c
/*
* life.c
*
* Created on: Sep 13, 2016
* Author: leune
*/
#include <stdio.h>
#include <unistd.h>
#include "life.h"
int main(int argc, char *argv[]) {
int board[XSIZE][YSIZE];
int rounds = DEFAULTROUNDS;
initBoard(board);
board[5][5] = ALIVE;
board[5][6] = ALIVE;
board[5][7] = ALIVE;
board[6][6] = ALIVE;
printf("Playing %d rounds.\n\n", rounds);
for (int i=0; i<rounds; i++) {
printf("Round: %d\n", i+1);
printBoard(board);
playRound(board);
sleep(1);
}
return 0;
}
void initBoard(int vBoard[][YSIZE]) {
/* write this function */
}
void playRound(int vBoard[][YSIZE]) {
int tmpBoard[XSIZE][YSIZE];
initBoard(tmpBoard);
// perform the algorithm on vBoard, but update tmpBoard
// with the new state
/* write this fragment */
// copy tmpBoard over vBoard
for (int y=0; y < YSIZE; y++) {
for (int x=0; x < XSIZE; x++) {
vBoard[x][y] = tmpBoard[x][y];
}
}
}
int onBoard(int x, int y) {
if (x < 0 || x >= XSIZE)
return 0;
else
if (y < 0 || y >= YSIZE) return 0;
else
return 1;
}
int neighbors(int vBoard[][YSIZE], int x, int y) {
int n=0;
int xp1 = x + 1;
int xm1 = x - 1;
int yp1 = y + 1;
int ym1 = y - 1;
if (onBoard(xm1, y) && vBoard[xm1][y] == ALIVE) n++;
if (onBoard(xm1, yp1) && vBoard[xm1][yp1] == ALIVE) n++;
if (onBoard(x, yp1) && vBoard[x][yp1] == ALIVE) n++;
if (onBoard(xp1, yp1) && vBoard[xp1][yp1] == ALIVE) n++;
if (onBoard(xp1, y) && vBoard[xp1][y] == ALIVE) n++;
if (onBoard(xp1, ym1) && vBoard[xp1][ym1] == ALIVE) n++;
if (onBoard(x, ym1) && vBoard[x][ym1] == ALIVE) n++;
if (onBoard(xm1, ym1) && vBoard[xm1][ym1] == ALIVE) n++;
return n;
}
void printBoard(int vBoard[XSIZE][YSIZE]) {
/* write this fragment */
}In: Computer Science