For this assignment, you will take on the role of software developer as part of a team of developers for a retail company. The payroll manager of the company has tasked you with developing a Java program (if you can put it in NetBeans that would be awesome) to quickly calculate an employee’s weekly gross and net pay. The program must prompt the user to enter the employee’s name, rate of pay, and hours worked. The output will display the information entered into the program along with the calculations for gross pay, total amount of deductions, and net pay.
In this coding assignment, you will utilize the Java syntax and techniques you learned while reviewing the required resources for Week 1. You may select appropriate variable names as long as proper Java syntax is used. You will also submit your source code.
Input:
In the input section, utilize Java syntax and techniques to input
the employee’s name, rate of pay, and hours worked. The input
should be completed either via keyboard or via file.
Processing:
In the processing section, the following calculations will need to
be performed in the processing section:
The following calculations are used to calculate each deduction:
Total deductions = Federal Tax amount + State Tax amount + Medicare amount + Social Security amount + Unemployment Insurance amount
Output:
The Java program should display the following information:
In: Computer Science
In this assignment will demonstrate your understanding of the following:
1. C++ classes;
2. Implementing a class in C++;
3. Operator overloading with chaining;
4. Preprocessor directives #ifndef, #define, and #endif;
5. this – the pointer to the current object.
In this assignment you will implement the Date class and test its functionality.
Consider the following class declaration for the class date:
class Date
{
public:
Date(); //default constructor; sets m=01, d=01, y =0001
Date(unsigned m, unsigned d, unsigned y);
//explicit-value constructor to set date equal to today's
//date. Use 2-digits for month (m) and day (d), and 4-digits for year (y); this function should //print a message if a leap year.
void display();//output Date object to the screen
int getMonth();//accessor to output the month
int getDay();//accessor to output the day
int getYear();//accessor to output the year
void setMonth(unsigned m);//mutator to change the month
void setDay(unsigned d);//mutator to change the day
void setYear(unsigned y);//mutation to change the year
friend ostream & operator<<(ostream & out, const Date & dateObj);//overloaded operator<< as a friend function with chaining
//you make add other functions if necessary
private:
int myMonth, myDay, myYear; //month, day, and year of a Date obj respectively };
You will implement all the constructors and member functions in the class Date. Please see the comments that follow each function prototype in the Date class declaration above; these comments describe the functionality that the function should provide to the class.
Please store the class declaration in the file “date.h” and the class implementation in the file “date.cpp” , and the driver to test the functionality of your class in the file “date_driver.cpp”.
S A M P L E O U T P U T FORAssignment#2
Below I have provided a skeleton with stubs and a driver to help you get started. Remember to separate the skeleton into the appropriate files, and to include the appropriate libraries.
You should submit the files “date.h” , “date.cpp” , and “date_driver.cpp” together in a zip file named with the format “lastname_firstname_date.zip” to Canvas before the due date and time. Usually the tool you use to create a zip file will automatically append “zip” to the end of the filename.
Notes:
1. ALL PROGRAMS SHOULD BE COMPILED USING MS VISUAL STUDIO C++!
2. Information on Month: 1 = January, 2 = February, 3= March, …, 12 = December
3. Test the functionality of your class in “date_driver.cpp” in the following order and include messages for each test:
a. Test default constructor
b. Test display
c. Test getMonth
d. Test getDay
e. Test getYear
f. Test setMonth
g. Test setDay
h. Test setYear
4. See sample output below.
5. See skeleton below.
S A M P L E O U T P U T FORAssignment#2
Default constructor has been called
01/01/0001
Explicit-value constructor has been called
12/31/1957
Explicit-value constructor has been called
Month = 15 is incorrect
Explicit-value constructor has been called
2/29/1956
This is a leap year
Explicit-value constructor has been called
Day = 30 is incorrect
Explicit-value constructor has been called
Year = 0000 is incorrect
Explicit-value constructor has been called
Month = 80 is incorrect
Day = 40 is incorrect
Year = 0000 is incorrect
12/31/1957
12
31
1957
myDate: 11/12/2015 test2Date: 02/29/1956 yourDate: 12/31/1957
Skeleton FOR Assignment#2
#include <iostream>
#include <iostring>
//#include "date.h"
using namespace std;
//*********************************************************************************************
//*********************************************************************************************
// D A T E . h
//This declaration should go in date.h
#ifndef DATE_H
#define DATE_H
class Date
{
public: Date(); //default constructor; sets m=01, d=01, y =0001 Date(unsigned m, unsigned d, unsigned y);
//explicit-value constructor to set date equal to today's
//date. Use 2-digits for month (m) and day (d), and 4-digits for year (y); this function should
//print a message if a leap year.
void display();//output Date object to the screen
int getMonth();//accessor to output the month
int getDay();//accessor to output the day
int getYear();//accessor to output the year
void setMonth(unsigned m);//mutator to change the month
void setDay(unsigned d);//mutator to change the day
void setYear(unsigned y);//mutation to change the year
friend ostream & operator<<(ostream & out, const Date & dateObj);//overloaded operator<< as a friend function with chaining
//you make add other functions if necessary
private:
int myMonth, myDay, myYear; //month, day, and year of a Date obj respectively };
#endif
//*********************************************************************************************
//*********************************************************************************************
// D A T E . C P P
//This stub (for now) should be implemented in date.cpp
//*************************************************************************************
//Name: Date
//Precondition: The state of the object (private data) has not been initialized
//Postcondition: The state has been initialized to today's date
//Description: This is the default constructor which will be called automatically when
//an object is declared. It will initialize the state of the class
//
//*************************************************************************************
Date::Date()
{
//the code for the default constructor goes here
}
//*************************************************************************************
//Name: Date
//Precondition:
//Postcondition:
//Description:
//
//
//*************************************************************************************
Date::Date(unsigned m, unsigned d, unsigned y)
{
}
//*************************************************************************************
//Name: Display
//Precondition:
//Postcondition:
//Description:
//
//
//*************************************************************************************
void Date::display()
{
}
//*************************************************************************************
//Name: getMonth
//Precondition:
//Postcondition:
//Description:
//
//
//*************************************************************************************
int Date::getMonth()
{
return 1;
}
//*************************************************************************************
//Name: getDay
//Precondition:
//Postcondition:
//Description:
//
//
//*************************************************************************************
int Date::getDay()
{
return 1;
}
//*************************************************************************************
//Name: getYear
//Precondition:
//Postcondition:
//Description:
//
//
//*************************************************************************************
int Date::getYear()
{
return 1;
}
//*************************************************************************************
//Name: setMonth
//Precondition:
//Postcondition:
//Description:
//
//
//*************************************************************************************
void Date::setMonth(unsigned m)
{
}
//*************************************************************************************
//Name: setDay
//Precondition:
//Postcondition:
//Description:
//
//
//*************************************************************************************
void Date::setDay(unsigned d)
{
}
//*************************************************************************************
//Name: getYear
//Precondition:
//Postcondition:
//Description:
//
//
//*************************************************************************************
void Date::setYear(unsigned y)
{
}
ostream & operator<<(ostream & out, const Date & dateObj)
{
return out;
}
//*********************************************************************************************
//*********************************************************************************************
// D A T E D R I V E R . C P P
//EXAMPLE OF PROGRAM HEADER
int main()
{
//Date myDate;
//Date yourDate(12,31, 1957);
//Date test1Date(15, 1, 1962);
//should generate error message that bad month
//Date test2Date(2, 29, 1956);
//ok, should say leep year
//Date test3Date(2, 30, 1956);
//should generate error message that bad day
//Date test4Date(12,31,0000);
//should generate error message that bad year
//Date test5Date(80,40,0000);
//should generate error message that bad month, day and year
//yourDate.display();
//cout<<yourDate.getMonth()<<endl;
//cout<<yourDate.getDay()<<endl;
//myDate.setMonth(11);
//myDate.setDay(12);
//myDate.setYear(2015);
//cout<<"myDate: "<<myDate<<" test2Date: "<<test2Date<<" yourDate: "<<yourDate<<endl;
return 0;
}
In: Computer Science
Visual Studio is an integrated development environment, which means that it combines an editor, compiler and debugger into a single interface. When you work on Matrix, you have to edit your program in Visual Studio and then compile and test on Matrix using the gcc compiler. Which set of tools do you prefer for programming? What are the advantages of your preferred tool set over the alternative? What do you think would be the difficulties in learning to use the tool set you least prefer?
In: Computer Science
/*
CIS 251 In Class Assignment
This program performs various operations on a ten
element int array.
*/
#include <iostream>
using namespace std;
void start (int boxes [10]);
void move (int squares [10], int x, int y, int z);
void add (int arr [10], int first, int last);
void print (int arr [10]);
int main ()
{
int my_arr [10];
cout << "The original array is:\n";
print (my_arr);
start (my_arr);
cout << "\n\nThe array after start is:\n";
print (my_arr);
move (my_arr, 2, 4, 6);
cout << "\n\nThe array after move is:\n";
print (my_arr);
add (my_arr, 3, 7);
cout << "\n\nThe array after add is:\n";
print (my_arr);
cout << "\n\n";
return 0;
}
void start (int boxes [10])
{
int index, count;
count = 17;
for (index = 0; index < 10; index++)
{
boxes [index] = count;
count--;
}
}
void move (int squares [10], int x, int y, int z)
{
int temp;
temp = squares [x];
squares [x] = squares [y];
squares [z] = squares [y];
squares [y] = temp;
}
void add (int arr [10], int first, int last)
{
int m;
for (m = first; m <= last; m++)
arr [m]++;
}
void print (int arr [10])
{
int z;
for (z = 0; z < 10; z++)
cout << z << " ";
}
Questions and Experiments:
1. The function print is supposed to print each element of the array but does not work. What does it print?
2. Now that print has been fixed, run your program again. Why did “funny” values show up for the first call to print?
3. The array has different names in the functions than it does in main. Explain why this is not a problem.
4. Would the program still work if the array had the same name in the functions as in main?
5. What values would be placed in the array by the function start if count was initially set equal to 0 instead of 17? Show the values.
6. Remove the { } associated with the for statement in the function start. Run your program and explain clearly why the output changes as shown.
Add the {} back to the program.
7. Say that we have an array, my_arr, with the following values:
5 9 3 4 6 12 19 22 3 4
[0] [1] [2] [3] [4] [5] [6] [7] [8] [9]
and the function move is called as follows:
move (my_arr, 1, 3, 5);
Show above how this call would change the array.
8. Explain clearly what the function add does. Include the parameters first and last in your explanation.
9. How would add change the array if called as follows:
add (my_arr, 7, 2);
Explain your answer.
In: Computer Science
3. In the handler code for the OK button, first check (as you did in Exercise 1 X) to ensure that the name is not blank. If the name is blank generate a message as requested in Exercise 1 X, reset focus and have the user try again to enter a non-blank name.
4. Once a non-blank name has been entered, dynamically (in your own code) enable the Enter Subtotal label and the Enter Subtotal text box.
5. Now in your handler code for btnCalculate, insert try-catch code (see p. 193 for an example) to catch an invalid decimal value entry and ask the user to re-enter his or her data.
6. Test your project and if the code you have added does not catch a negative input value, make sure you correct this problem and retest your project.
This is the code that I have.
namespace InvoiceTotal
{
public partial class frmInvoiceTotal : Form
{
public frmInvoiceTotal()
{
InitializeComponent();
}
int numberOfInvoices = 0;
decimal totalOfInvoices = 0m;
decimal invoiceAverage = 0m;
decimal largestInvoice = 0m;
decimal smallestInvoice =
Decimal.MaxValue;
private void
btnCalculate_Click(object sender, EventArgs e)
{
decimal subtotal
= Convert.ToDecimal(txtEnterSubtotal.Text);
decimal
discountPercent = .25m;
decimal
discountAmount = Math.Round(subtotal * discountPercent, 2);
decimal
invoiceTotal = subtotal - discountAmount;
txtSubtotal.Text = subtotal.ToString("c");
txtDiscountPercent.Text = discountPercent.ToString("p1");
txtDiscountAmount.Text = discountAmount.ToString("c");
txtTotal.Text =
invoiceTotal.ToString("c");
numberOfInvoices++;
totalOfInvoices
+= invoiceTotal;
invoiceAverage =
totalOfInvoices / numberOfInvoices;
largestInvoice =
Math.Max(largestInvoice, invoiceTotal);
smallestInvoice
= Math.Min(smallestInvoice, invoiceTotal);
txtNumberOfInvoices.Text = numberOfInvoices.ToString();
txtTotalOfInvoices.Text = totalOfInvoices.ToString("c");
txtInvoiceAverage.Text = invoiceAverage.ToString("c");
txtLargestInvoice.Text = largestInvoice.ToString("c");
txtSmallestInvoice.Text = smallestInvoice.ToString("c");
txtEnterSubtotal.Text = "";
txtEnterSubtotal.Focus();
}
private void
btnClearTotals_Click(object sender, System.EventArgs e)
{
numberOfInvoices
= 0;
totalOfInvoices
= 0m;
invoiceAverage =
0m;
largestInvoice =
0m;
smallestInvoice
= Decimal.MaxValue;
txtNumberOfInvoices.Text = "";
txtTotalOfInvoices.Text = "";
txtInvoiceAverage.Text = "";
txtLargestInvoice.Text = "";
txtSmallestInvoice.Text = "";
txtEnterSubtotal.Focus();
}
private void
btnExit_Click(object sender, EventArgs e)
{
this.Close();
}
}
}
In: Computer Science
In: Computer Science
What are design patterns in object oriented programming?
Minimum 200 words
In: Computer Science
The biggest mysteries of the IEEE 754 Floating-Point Representation are “hidden bit” and “Bias.
Can someone explain to me why the "hidden bits" and "bias" are considered to be mysteries for the IEEE 754 floating point representation
In: Computer Science
Android Studio (Java)
I'm trying to create a simple calculator. I want to put out a message if they try to divide by 0.
I have this so far. What code should I put?
divide.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (number1.getText().length() != 0 && number2.getText().length() != 0) { double n1= Double.parseDouble(number1.getText().toString()); double n2= Double.parseDouble(number2.getText().toString()); double res= n1 / n2; result.setText(String.valueOf(res)); } else { Toast.makeText(view.getContext(), "Please enter the numbers properly", Toast.LENGTH_SHORT).show(); } } });
In: Computer Science
There are issue the muy code
The Body Mass Index (BMI) is a calculation used to categorize whether a person’s weight is at a healthy weight for a given height. The formula is as follows:
bmi = kilograms / (meters2)
where kilograms = person’s weight in kilograms, meters = person’s height in meters
BMI is then categorized as follows:
Classification |
BMI Range |
Underweight |
Less than 18.5 |
Normal |
18.5 or more, but less than 25.0 |
Overweight |
25.0 or more, but less than 30.0 |
Obese |
30.0 or more |
To convert inches to meters:
meters = inches / 39.37
To convert pounds (lbs) to kilograms:
kilograms = lbs / 2.2046
Assignment
Ask the user for their weight in pounds and height in inches. Compute their BMI and BMI classification and output the results.
The program must implement and use the following methods:
convertToKilograms – convert pounds to kilograms
convertToMeters – convert inches to meters
calcBMI – take weight in kilograms and height in meters and return the BMI
bmiClassification – take the value for the BMI and return a String with the BMI classification
Use the following code as a starting point for your assignment:
import java.util.Scanner;
// TODO Student name, date,
purpose
public class Main {
private static Scanner
input = new
Scanner(System.in);
public static void
main(String[] args) {
double
lbs, inches, meters, kgs, bmi;
String
classification;
// TODO
add code here
}
// TODO add your methods here
(make them static)
}
As always use the package name edu.cscc and include a comment with your name, the date, and the purpose of the program.
Example Output
Calculate BMI
Enter weight (lbs): 200
Enter height (inches): 72
Your BMI is 27.124767811523153
Your BMI classification is Overweight
My code:
public class Main { private static Scanner input = new Scanner(System.in); public static void main(String[] args) { double lbs, inches, meters, kgs, bmi; String classification; System.out.println("Calculate BMI"); System.out.println("Enter weight(lbs):"); lbs = input.nextDouble(); System.out.println("Enter height (inches):"); meters = input.nextDouble() * 0.0254; //Converting pounds to kegs kgs = lbs / 2.2; //Calculation of BMI bmi = calculateBMI(kgs, meters); //Classification of bmi classification = classify(bmi); System.out.println("Your BMI is " + bmi); System.out.println("Your BMI classification is " + classification); } public static double calculateBMI(double weight,double height) { return weight/ (height*height); } // Classify the BMI to string public static String classify(double bmi) { if(bmi < 18.5) { return "Underweight"; }else if(bmi < 25.0) { return "Normal"; }else if(bmi < 30.0) { return "Overweight"; }else { return "Obese"; } } }
In: Computer Science
Cyber security
Security Policy:
Security Recommendation: Rose Shumba manages the IT security for a school. Given the wide range of people who use the school’s computers, it is challenging for Rose to prevent virus infections. She has installed an anti-virus on each machine and has a policy prohibiting software downloads.
Comment on:
In: Computer Science
In C++, Write the following program using a vector:
A common game is the lottery card. The card has numbered spots of which a certain number are selected at random. Write a Lotto() function that takes two arguments. The first should be the number of spots on a lottery card and the second should be the number of spots selected at random. The function should return a vector object that contains, in sorted order, the numbers selected at random. Use your function as follows:
Vector winners;
winners = Lotto(51,6);
This would assign to winners a vector that contains six numbers selected randomly from the range 1 through 51.
Also write a short program that lets you test the function,
In: Computer Science
Using Visual Studio in C#; create a grading application for a class of ten students. The application should request the names of the students in the class. Students take three exams worth 100 points each in the class. The application should receive the grades for each student and calculate the student’s average exam grade. According to the average, the application should display the student’s name and the letter grade for the class using the grading scheme below. Grading Scheme: • A = 90-100 • B = 80-89 • C = 70-79 • D = 60-69 • F = <60
In: Computer Science
Question: In a package named "oop" create a Scala class named "Team" and a Scala object named "Referee". Team will have:
• State values of type Int representing the strength of the team's offense and defense with a constructor to set these values. The parameters for the constructor should be offense then defense
• A third state variable named "score" of type Int that is not in the constructor, is declared as a var, and is initialized to 0 Referee will have:
• A method named "playGame" that takes two Team objects as parameters and return type Unit. This method will alter the state of each input Team by setting their scores equal to their offense minus the other Team's defense. If a Team's offense is less than the other Team's defense their score should be 0 (no negative scores)
• A method named "declareWinner" that takes two Teams as parameters and returns the Team with the higher score. If both Teams have the same score, return a new Team object with offense and defense both set to 0
In: Computer Science
In: Computer Science