|
----------------------------------------------------------------------------------------------------------------------------------------------
scratchOffs fucntion:
int playScratchOffs(int cash)
{
printf("Let's play scratch off tickets!\n");
return cash;
}
----------------------------------------------------------------------------------------------------------------------------------------------
My Code So Far:
//define struct OneDollar
struct OneDollar {
int winNumber;
int numbers [5];
float prizes [5];
char bonus [2];
int oneSO;
} OneDollar;
//define struc TwoDollar
struct TwoDollar {
int winNumbers [2];
int numbers [10];
float prizes [10];
char bounus [2];
int twoSO;
} TwoDollar;
// define struc FiveDollar
struct FiveDollar {
int winNumbers [4];
int numbers [12];
float prizes [12];
char bonus [4];
int fiveSO;
} FiveDollar;
//function declaration for a. createScratchOffOne
int createScratchOffOne ();
//function declaration for b. displayScratchOffOne
int displayScratchOffOne ();
//function declaration for c. createScratchOffTwo
int createScratchOffTwo ();
//function declaration for d. displayScratchOffTwo
int displayScratchOffTwo ();
//function declaration for e. createScratchOffFive
int createScratchOffFive ();
//function declaration for f. displayScratchOffFive
int displayScratchOffFive ();
int playScratchOffs(int cash)
{
//declare integer variables
int type;
int count;
int c;
//variable declaration with structure
int main () {
struct OneDollar (oneSO);
struct TwoDollar (twoSO);
struct FiveDollar (fiveSO);
}
printf("Let's play scratch off tickets!\n");
printf("Players can select from OneDollar, TwoDollar and FiveDollar
tickets\n");
printf("Prizes are based on the ticket selected\n");
clearScreen();
printf ("Which type of scratch off would you like\n");
printf ("(1 = One Dollar, 2 = Two Dollar, 5 = Five
Dollar)?\n");
printf ("How many scratch offs would you like?\n");
return cash;
}
In: Computer Science
1. Update the HTML so the table has the caption and data shown in the second table.
a. Implement the table as a figure and use the figure caption to supply the table caption.
2. Expand the CSS so it does the formatting shown in the second table.
b. Use pseudo-classes to achieve colors
CODE:
<!DOCTYPE html>
<html lang="en">
<head>
<title>Employee table</title>
<meta name="description" content="Activity">
<meta charset="UTF-8">
<link rel="stylesheet" type="text/css" href="Activity2.css">
</head>
<body>
<table>
<thead>
<tr>
<th>Name</th>
<th>E-mail</th>
<th class="right">Years of Service</th>
</tr>
</thead>
<tbody>
<tr>
<td>Joel Murach</td>
<td>[email protected]</td>
<td class="right">22</td>
</tr>
<tr>
<td>Anne Boehm</td>
<td>[email protected]</td>
<td class="right">34</td>
</tr>
<tr>
<td>Zak Ruvalcaba</td>
<td>[email protected]</td>
<td class="right">4</td>
</tr>
<tr>
<td>Judy Taylor</td>
<td>[email protected]</td>
<td class="right">39</td>
</tr>
<tr>
<td>Cyndi Vasquez</td>
<td>[email protected]</td>
<td class="right">10</td>
</tr>
<tr>
<td>Kelly Slivkoff</td>
<td>[email protected]</td>
<td class="right">25</td>
</tr>
<tr>
<td>Juliette Baylon</td>
<td>[email protected]</td>
<td class="right">1</td>
</tr>
</tbody>
</table>
<footer>
<a href="https://validator.w3.org/check?uri=referer">Validate HTML</a> <br>
<a href="https://jigsaw.w3.org/css-validator/check/referer">Validate CSS</a>
</footer>
</body>
</html>
CSS:
body
{
width: 750px;
margin: 0 auto;
}
table
{
border-collapse: collapse;
border: 1px solid black;
margin: 20px;
}
thead
{
background-color: yellow;
}
th, td
{
border: 1px solid black;
padding: .2em 1em .2em .5em;
text-align: left;
vertical-align: middle;
}
.right
{
text-align: right;
}
tbody tr:nth-child(even) td
{
background-color: yellow;
}
In: Computer Science
Using Netbeans update the Sales project so the input and the output are done through a GUI of your choice.
The classes design should not be changed, only the code in the test class.
public abstract class Account {
private int accountId;
public Account(int id){
this.accountId=id;
}
//getters
public int getAccountId() {
return accountId;
}
//setters
public void setAccountId(int accountId) {
}
//abstract method to calculate sales
public abstract double calculateSales();
//to string method
@Override
public String toString() {
return("Account ID:"+getAccountId());
}
}
public class Services extends Account {
private int numberOfHours;
private double ratePerHour;
public Services(int id, int numberOfHours, double
ratePerHours){
super(id);
this.numberOfHours=numberOfHours;
this.ratePerHour=ratePerHours;
}
//getters
public int getNumberOfHours() {
return numberOfHours;
}
public double getRatePerHour() {
return ratePerHour;
}
//setters
public void setNumberOfHours() {
this.numberOfHours=numberOfHours;
}
public void setRatePerHour() {
this.ratePerHour=ratePerHour;
}
//using the abstract method from Account
public double calculateSales() {
return getNumberOfHours() * getRatePerHour();
}
//toString method to put info in a readable format
@Override
public String toString() {
return super.toString()+", Rate per Hour: $"+getRatePerHour()+",
Hours worked: "+ getNumberOfHours()+", Total Sales:
$"+calculateSales();
}
}
public class Supplies extends Account {
private int numberOfItems;
private double pricePerItem;
public Supplies(int id, int numberOfItems, double
pricePerItem){
super(id);
this.numberOfItems=numberOfItems;
this.pricePerItem=pricePerItem;
}
//getters
public int getNumberOfItems() {
return numberOfItems;
}
public double getPricePerItem() {
return pricePerItem;
}
//setters
public void setNumberOfItems() {
this.numberOfItems=numberOfItems;
}
public void setPricePerItem() {
this.pricePerItem=pricePerItem;
}
//using the abstract method from Account
public double calculateSales() {
return getNumberOfItems() * getPricePerItem();
}
//toString method to put info in a readable format
@Override
public String toString() {
return super.toString()+", Item Price: $"+getPricePerItem()+",
Number of Items: "+ getNumberOfItems()+", Total Sales:
$"+calculateSales();
}
}
TEST CLASS
public class companySales {
public static void main(String[] args) {
Account[] accounts;
accounts = new Account[100];
accounts[0] = new Supplies(1, 50, 4.50);
accounts[1] = new Services(2, 5, 25.50);
for(int x=0;x<2;++x){
System.out.println(accounts[x].toString());
}
}
}
In: Computer Science
After running the experiment with the pivot, comment out the line, update the pivot selection to use the median of the first, middle, and last items, and run the experiment.
What line needs to be commented out and how would I update the pivot selection to use the median?
Example.java
package sorting;
import java.io.IOException;
import java.util.Random;
import sorters.QuickSort;
public class Example {
public static void main(String args[]) throws
IOException {
int n = 100; // adjust
this to the number of items to sort
int runs = 11;
partB(n, runs);
public static void partB(int n, int runs) {
int [] data = new int[n];
QuickSort quicksort = new
QuickSort();
labels(runs);
for (int i = 0; i < runs; i++)
{
randomArray(data);
quicksort.sort(data);
}
System.out.println();
}
public static void labels(int runs) {
for(int i = 0; i < runs; i++)
{
String label =
"Run " + i;
System.out.printf("%12s ", label);
}
System.out.println();
}
public static void randomArray(int [] data) {
Random rand = new
Random();
for(int j = 0; j < data.length;
j++) {
data[j] =
rand.nextInt();
}
}
}
QuickSort.java
package sorters;
// note that this class can only sort primitive ints correctly.
public class QuickSort {
private int[] items;
public void sort(int[] items) {
this.items = items;
long start =
System.nanoTime();
quicksort(0, items.length-1);
long finish =
System.nanoTime();
//System.out.println(Arrays.toString(items));
System.out.printf("%12s ",
finish-start);
}
private int partition(int left, int right) {
int i = left;
int j = right;
int temp;
int pivot = (int) items[(left
+ right) / 2];
while (i <= j) {
while((int)
items[i] < pivot)
i++;
while((int) items[j] > pivot)
j--;
if(i
<= j) {
temp = items[i];
items[i] = items[j];
items[j] = temp;
i++;
j--;
}
}
return i;
}
private void quicksort(int left, int right) {
int index = partition(left, right);
if(left < index -
1)
quicksort(left,
index-1);
if(index < right)
quicksort(index, right);
}
}
In: Computer Science
I want to update this JAVA program to : Exit cleanly, and change the pie chart to circle rather than an oval, and provide a separate driver please and thank you
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Rectangle;
import java.util.Scanner;
import javax.swing.JComponent;
import javax.swing.JFrame;
// class to store the value and color mapping of the
// pie segment(slices)
class Segment {
double value;
Color color;
// constructor
public Segment(double value, Color color) {
this.value = value;
this.color = color;
}
}
class pieChartComponent extends JComponent {
private static final long serialVersionUID = 1L;
Segment[] Segments;
// Parameterized constructor
// create 4 segments of the pie chart
pieChartComponent(int v1, int v2, int v3, int v4) {
Segments = new Segment[] { new Segment(v1, Color.black), new
Segment(v2, Color.green), new Segment(v3, Color.yellow),
new Segment(v4, Color.red) };
}
// function responsible for calling the worker method
drawPie
public void paint(Graphics g) {
drawPie((Graphics2D) g, getBounds(), Segments);
}
// worker function for creating the percentage wise slices of
the pie chart
void drawPie(Graphics2D g, Rectangle area, Segment[] Segments)
{
double total = 0.0D;
// fin the total of the all the inputs provided by the user
for (int i = 0; i < Segments.length; i++) {
total += Segments[i].value;
}
// Initialization
double curValue = 0.0D;
int strtAngle = 0;
// iterate till all the segments are covered
for (int i = 0; i < Segments.length; i++) {
// compute start angle, with percentage
strtAngle = (int) (curValue * 360 / total);
// find the area angle of the segment
int arcAngle = (int) (Segments[i].value * 360 / total);
g.setColor(Segments[i].color);
g.fillArc(area.x, area.y, area.width, area.height, strtAngle,
arcAngle);
curValue += Segments[i].value;
}
}
}
public class Graphic_Pie2D {
public static void main(String[] argv) {
System.out.println("Pleae provide 4 values, to create the pie
chart");
Scanner input = new Scanner(System.in);
int v1, v2, v3, v4;
v1 = input.nextInt();
v2 = input.nextInt();
v3 = input.nextInt();
v4 = input.nextInt();
// create a JFrame with title
JFrame frame = new JFrame("Pie Chart");
frame.getContentPane().add(new
pieChartComponent(v1,v2,v3,v4));
frame.setSize(500, 300);
frame.setVisible(true);
}
}
here's the assignment for reference :
Pie chart: prompt the user (at the command line) for 4 positive integers, then draw a pie chart in a window. Convert the numbers to percentages of the numbers’ total sum; color each segment differently; use Arc2D. No text fields (other than the window title) are required. Provide a driver in a separate source file to test your class.
In: Computer Science
Chapter 6: Use a list to store the players
Update the program in python so that it allows you to store the players for the starting lineup. This
should include the player’s name, position, at bats, and hits. In addition, the program
should calculate the player’s batting average from at bats and hits.
Console
================================================================
Baseball Team Manager
MENU OPTIONS
1 – Display lineup
2 – Add player
3 – Remove player
4 – Move player
5 – Edit player position
6 – Edit player stats
7 - Exit program
POSITIONS
C, 1B, 2B, 3B, SS, LF, CF, RF, P
================================================================
Menu option: 2
Name: Mike
Position: C
At bats: 0
Hits: 0
Mike was added.
Menu option: 1
Player POS AB H AVG
----------------------------------------------------------------
1 Joe P 10 2 0.2
2 Tom SS 11 4 0.364
3 Ben 3B 0 0 0.0
4 Mike C 0 0 0.0
Menu option: 6
Lineup number: 4
You selected Mike AB=0 H=0
At bats: 4
Hits: 1
Mike was updated.
Menu option: 4
Current lineup number: 4
Mike was selected.
New lineup number: 1
Mike was moved.
Menu option: 7
Bye!
Specifications
Use a list of lists to store each player in the lineup.
Use a tuple to store all valid positions (C, 1B, 2B, etc).
Make sure that the user’s position entries are valid.
In: Computer Science
Chapter 6: Use a list to store the players
In Python, Update the program so that it allows you to store the players for the starting lineup. This
should include the player’s name, position, at bats, and hits. In addition, the program
should calculate the player’s batting average from at bats and hits.
Console
================================================================
Baseball Team Manager
MENU OPTIONS
1 – Display lineup
2 – Add player
3 – Remove player
4 – Move player
5 – Edit player position
6 – Edit player stats
7 - Exit program
POSITIONS
C, 1B, 2B, 3B, SS, LF, CF, RF, P
================================================================
Menu option: 2
Name: Mike
Position: C
At bats: 0
Hits: 0
Mike was added.
Menu option: 1
Player POS AB H AVG
----------------------------------------------------------------
1 Joe P 10 2 0.2
2 Tom SS 11 4 0.364
3 Ben 3B 0 0 0.0
4 Mike C 0 0 0.0
Menu option: 6
Lineup number: 4
You selected Mike AB=0 H=0
At bats: 4
Hits: 1
Mike was updated.
Menu option: 4
Current lineup number: 4
Mike was selected.
New lineup number: 1
Mike was moved.
Menu option: 7
Bye!
Specifications
Use a list of lists to store each player in the lineup.
Use a tuple to store all valid positions (C, 1B, 2B, etc).
Make sure that the user’s position entries are valid.
In: Computer Science
Tables:
Create table Item( &nbs...
Bookmark
Tables:
Create table Item(
ItemId char(5) constraint itmid_unique primary key,
Decription varchar2(30),
Unitcost number(7,2));
Create table Customer(
custID char(5) constraint cid.unique primary key,
custName varchar2(20),
address varchar2(50));
Create table Orderdata(
orderID char(5) constraint oid_uniq primary key,
orderdate date,
shipdate date,
ItemId char(5) references Item.ItemId,
No_of_items number(4),
Unitcost number(7,2),
Order_total number(7,2),
custID char(5) references customer.custID);
Insert Into Item values(‘A123’,’Pencil’,2.5);
Insert Into Item values(‘B123’,’Pen’,15);
Insert Into Customer(‘C123’,’ABC Gen stores’,’Sanfransico’);
Insert Into Customer(‘C132’,’XYZ stores’,’California’);
Insert into Orderdata(‘o123’,’12-aug-2016’,’12-aug-2016’,’A123’,5,2.5,12.5,’c123’);
Insert into Orderdata(‘o124’,’14-aug-2016’,’14-aug-2016’,’B123’,5,15,75,’c132’);
_____________________________________________________________
Enhance your Module 5 CT database table structures, via your selected RDBMS, as you wish.
, using SQL and an SQL script file, create and execute advanced queries of your choice that demonstrate each of the following:
The use of a GROUP BY clause, with a HAVING clause, and one or more group functions
The use of UNION operator
The use of a subquery
The use of an outer join
Then create and execute at least one SQL UPDATE and at least one SQL DELETE query.
Finally, create and use an SQL view and in a SELECT query.
Submit the following outputs of your SQL script file processing, in this order and appropriately labeled, in a single Word file:
The SQL and results of your INSERT statements to further populate your tables
The SQL and results of your 4 advanced SELECT queries
The SQL and results of your UPDATE and DELETE queries
The SQL and results of your view creation and its use in a SELECT query
You must show all of your SQL as it executed in Management Studio or other development environments. This includes the results returned by your selected RDBMS.
(((((((((((Note)))))))))))))))): you must populate any other tables and show the execution of your SQL statements as required.
Use a SELECT statement using the UNION operator.
create a view and use it in a SELECT query...
In: Computer Science
1).Modify the project so that records are inserted into the random access file in ascending order using an insertion sort methodology with the Social Security Number acting as the key value. This requires defining the method compareTo() in the Personal and Student classes to be used in a modified method add() in Database. The method finds a proper position for a record d, moves all the records in the file to make room for d, and writes d into the file.
2. With the new organization of the data files. find() and modify() must also be modified. Both methods should now stop their sequential search when they encounter a record greater than the record looked for, or they reach the end of the file.
I am having trouble initializing the compareTo()
Personal.java
import java.io.*;
import java.util.Arrays;
import Student.Student;
public class Personal extends IOmethods implements DbObject
{
protected final int nameLen = 10, cityLen = 10;
protected String SSN, name, city;
protected int year;
protected long salary;
protected final int size = 9*2 + nameLen*2 + cityLen*2 + 4 +
8;
Personal() {
}
Personal(String ssn, String n, String c, int y, long s) {
SSN = ssn; name = n; city = c; year = y; salary = s;
}
public int size() {
return size;
}
public void writeToFile(RandomAccessFile out) throws IOException
{
writeString(SSN,out);
writeString(name,out);
writeString(city,out);
out.writeInt(year);
out.writeLong(salary);
}
public void writeLegibly() {
System.out.print("SSN = " + SSN + ", name = " + name.trim()
+ ", city = " + city.trim() + ", year = " + year
+ ", salary = " + salary);
}
public void readFromFile(RandomAccessFile in) throws IOException
{
SSN = readString(9,in);
name = readString(nameLen,in);
city = readString(cityLen,in);
year = in.readInt();
salary = in.readLong();
}
public void readKey() throws IOException {
System.out.print("Enter SSN: ");
SSN = readLine();
}
public void readFromConsole() throws IOException {
System.out.print("Enter SSN: ");
SSN = readLine();
System.out.print("Name: ");
name = readLine();
for (int i = name.length(); i < nameLen; i++)
name += ' ';
System.out.print("City: ");
city = readLine();
for (int i = city.length(); i < cityLen; i++)
city += ' ';
System.out.print("Birthyear: ");
year = Integer.valueOf(readLine().trim()).intValue();
System.out.print("Salary: ");
salary = Long.valueOf(readLine().trim()).longValue();
}
public void copy(DbObject[] d) {
d[0] = new Personal(SSN,name,city,year,salary);
}
public int compareTo(String p) {
}
}
Student.java
import java.io.*;
public class Student extends Personal {
public int size() {
return super.size() + majorLen*2;
}
protected String major;
protected final int majorLen = 10;
Student() {
super();
}
Student(String ssn, String n, String c, int y, long s, String m)
{
super(ssn,n,c,y,s);
major = m;
}
public void writeToFile(RandomAccessFile out) throws IOException
{
super.writeToFile(out);
writeString(major,out);
}
public void readFromFile(RandomAccessFile in) throws IOException
{
super.readFromFile(in);
major = readString(majorLen,in);
}
public void readFromConsole() throws IOException {
super.readFromConsole();
System.out.print("Enter major: ");
major = readLine();
for (int i = major.length(); i < nameLen; i++)
major += ' ';
}
public void writeLegibly() {
super.writeLegibly();
System.out.print(", major = " + major.trim());
}
public void copy(DbObject[] d) {
d[0] = new Student(SSN,name,city,year,salary,major);
}
public int compareTo() {
}
}
DbObject.java
import java.io.*;
public interface DbObject {
public void writeToFile(RandomAccessFile out) throws
IOException;
public void readFromFile(RandomAccessFile in) throws
IOException;
public void readFromConsole() throws IOException;
public void writeLegibly() throws IOException;
public void readKey() throws IOException;
public void copy(DbObject[] db);
public int size();
}
IOmethods,java
import java.io.*;
public class IOmethods {
public void writeString(String s, RandomAccessFile out) throws
IOException {
for (int i = 0; i < s.length(); i++)
out.writeChar(s.charAt(i));
}
public String readString(int len, RandomAccessFile in) throws
IOException {
String s = "";
for (int i = 0; i < len; i++)
s += in.readChar();
return s;
}
public String readLine() throws IOException {
int ch;
String s = "";
while (true) {
ch = System.in.read();
if (ch == -1 || (char)ch == '\n') // end of file or end of
line;
break;
else if ((char)ch != '\r') // ignore carriage return;
s = s + (char)ch;
}
return s;
}
}
Database.java
import java.io.*;
public class Database {
private RandomAccessFile database;
private String fName = new String();;
private IOmethods io = new IOmethods();
Database() throws IOException {
System.out.print("File name: ");
fName = io.readLine();
}
private void add(DbObject d) throws IOException {
database = new RandomAccessFile(fName,"rw");
database.seek(database.length());
d.writeToFile(database);
database.close();
}
private void modify(DbObject d) throws IOException {
DbObject[] tmp = new DbObject[1];
d.copy(tmp);
database = new RandomAccessFile(fName,"rw");
while (database.getFilePointer() < database.length()) {
tmp[0].readFromFile(database);
if (tmp[0].equals(d)) {
tmp[0].readFromConsole();
database.seek(database.getFilePointer()-d.size());
tmp[0].writeToFile(database);
database.close();
return;
}
}
database.close();
System.out.println("The record to be modified is not in the
database");
}
private boolean find(DbObject d) throws IOException {
DbObject[] tmp = new DbObject[1];
d.copy(tmp);
database = new RandomAccessFile(fName,"r");
while (database.getFilePointer() < database.length()) {
tmp[0].readFromFile(database);
if (tmp[0].equals(d)) {
database.close();
return true;
}
}
database.close();
return false;
}
private void printDb(DbObject d) throws IOException {
database = new RandomAccessFile(fName,"r");
while (database.getFilePointer() < database.length()) {
d.readFromFile(database);
d.writeLegibly();
System.out.println();
}
database.close();
}
public void run(DbObject rec) throws IOException {
String option;
System.out.println("1. Add 2. Find 3. Modify a record; 4.
Exit");
System.out.print("Enter an option: ");
option = io.readLine();
while (true) {
if (option.charAt(0) == '1') {
rec.readFromConsole();
add(rec);
}
else if (option.charAt(0) == '2') {
rec.readKey();
System.out.print("The record is ");
if (find(rec) == false)
System.out.print("not ");
System.out.println("in the database");
}
else if (option.charAt(0) == '3') {
rec.readKey();
modify(rec);
}
else if (option.charAt(0) != '4')
System.out.println("Wrong option");
else return;
printDb(rec);
System.out.print("Enter an option: ");
option = io.readLine();
}
}
}
UseDatabase.java
import java.io.IOException;
public class UseDatabase {
static public void main(String a[]) throws IOException {
// (new Database()).run(new Personal());
(new Database()).run(new Student());
}
}
In: Computer Science
|
Amy Ltd: comparison to previous year |
|||
|
2017 |
2018 |
2019 |
|
|
Accounts receivable |
1.20% |
8.2% |
7.4% |
|
Inventory |
8.4% |
1.7% |
4.9% |
|
Sales |
-3.0% |
1.2% |
5.4% |
|
Non-current assets |
2.3% |
4.8% |
7.6% |
|
Borrowings |
3% |
9.8% |
19.8% |
Required: provide a brief report on the results of the analysis? Comments should include any concerns you may have
In: Accounting