1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Kryger [21]
3 years ago
12

Create an application named SalesTransactionDemo that declares several SalesTransaction objects and displays their values and th

eir sum. The SalesTransaction class contains fields for a salesperson name, sales amount, and commission and a readonly field that stores the commission rate. Include three constructors for the class. One constructor accepts values for the name, sales amount, and rate, and when the sales value is set, the constructor computes the commission as sales value times the commission rate. The second constructor accepts a name and sales amount, but sets the commission rate to 0. The third constructor accepts a name and sets all the other fields to 0. An overloaded + operator adds the sales values for two SalesTransaction objects.
Computers and Technology
1 answer:
crimeas [40]3 years ago
8 0

Answer:

Explanation:

The following code is all written in Java, first I will add the object initialization and declaration code that can be added to the main method of any program. Then I have also written the entire SalesTransaction class as the question was not clear as to exactly which was needed.

//Object Creation to copy and paste into main method

SalesTransaction sale1 = new SalesTransaction("Gabriel", 25, 5);

SalesTransaction sale2 = new SalesTransaction("Daniela", 5);

SalesTransaction sale3 = new SalesTransaction("Jorge");

//SalesTransaction class with three constructors

package sample;

class SalesTransaction {

   String name;

   int salesAmount, commission;

   private int commissionRate;

   public SalesTransaction(String name, int salesAmount, int rate) {

       this.name = name;

       this.salesAmount = salesAmount;

       this.commissionRate = rate;

       commission = salesAmount * rate;

   }

   public SalesTransaction(String name, int salesAmount) {

       this.name = name;

       this.salesAmount = salesAmount;

       this.commissionRate = 0;

   }

   public SalesTransaction(String name) {

       this.name = name;

       this.salesAmount = 0;

       this.commissionRate = 0;

   }

}

You might be interested in
What does Iamo mean? i keep on hearing it and idk what it means
k0ka [10]

Answer:

laughing my ars e off

Explanation:

AAAAAAAAHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH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HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH

6 0
3 years ago
Read 2 more answers
What is a subjective point of view
anastassius [24]

Answer:

one based on opinion rather than fact, upon which reasonable people could disagree.

Explanation:

An example of a subjective point of view is a position taken on whether a movie or book is good or bad

6 0
3 years ago
Read 2 more answers
Write a program that reads in an integer value for n and then sums the integers from n to 2 * n if n is nonnegative, or from 2 *
devlian [24]

Answer:

Following are the program in c++

First code when using for loop

#include<iostream> // header file  

using namespace std; // namespace

int main() // main method

{

int n, i, sum1 = 0; // variable declaration

cout<<"Enter the number: "; // taking the value of n  

cin>>n;

if(n > 0) // check if n is nonnegative

{

for(i=n; i<=(2*n); i++)

{

sum1+= i;

}

}

else //  check if n  is negative

{

for(i=(2*n); i<=n; i++)

{

sum1+= i;

}

}

cout<<"The sum is:"<<sum1;

return 0;

Output

Enter the number: 1

The sum is:3

second code when using while loop

#include<iostream> // header file  

using namespace std; // namespace

int main() // main method

{

int n, i, sum1 = 0; // variable declaration

cout<<"Enter the number: "; // taking the value of n  

cin>>n;

if(n > 0) // check if n is nonnegative

{

int i=n;  

while(i<=(2*n))

{

sum1+= i;

i++;

}

}

else //  check if n  is negative

{

int i=n;  

while(i<=(2*n))

{

sum1+= i;

i++;

}

}

cout<<"The sum is:"<<sum1;

return 0;

}

Output

Enter the number: 1

The sum is:3

Explanation:

Here we making 2 program by using different loops but using same logic

Taking a user input in "n" variable.

if n is nonnegative then we iterate the loops  n to 2 * n and storing the sum in "sum1" variable.

Otherwise iterate a loop  2 * n to n and storing the sum in "sum1" variable.  Finally display  sum1 variable .

4 0
3 years ago
What is remote assistance?
Slav-nsk [51]

Answer:

Quick Assist, Windows 10 feature, allows a user to view or control a remote Windows computer over a network or the Internet to resolve issues without directly touching the unit. It is based on the Remote Desktop Protocol.

Explanation:

.....

3 0
3 years ago
Write a program that does the following: 1. Uses a menu system 2. Creates an array with 25 rows and an unknow number of columns
Vilka [71]

Answer:

import java.util.Scanner;

/**

*

* @author pc

*/

public class JaggedARrayAssignment {

private static int students[][] = new int[25][];//create a jagged array having 25 rows and unknown columns

public static void menu()

{

int index=0;//intitalize number of students to zero intially

Scanner sc=new Scanner(System.in);// create scanner for taking input from user

int choice;//choice

int maxExams=0;//maximum number of exams taken by any student

do

{

//print the menu

System.out.println("1-Input grades for next student");

System.out.println("2-Display the exam Average by student");

System.out.println("3-Display the exam Average by exam");

System.out.println("4-Display the current class average for all exams");

System.out.println("5-Exit");

choice=sc.nextInt();

//if choice is 1

if(choice==1)

{//ask how many xams

System.out.println("Please enter how many exams this student has taken?");

int noOfExams=sc.nextInt();//take input

students[index]=new int[noOfExams];//intialize array index by no of exams

System.out.println("Please enter the each of those exam scores one by one");//enter scores

if(maxExams<noOfExams)//if this noofexams is greater then update maxexams

maxExams=noOfExams;

//take scores from user

for(int i=0;i<noOfExams;i++)

{

students[index][i]=sc.nextInt();

}

index++;//increase index

}

else if(choice==2)

{

//calculate avregage by student and print it

System.out.println("*** Average by Student Id ***");

System.out.println("Student Id\tAverage Score");

for(int i=0;i<index;i++)

{

System.out.print((i+1)+"\t");//print student id

int sum=0;

//calculate sum

for(int j=0;j<students[i].length;j++)

{

sum=sum+students[i][j];

}

double avg=sum*1.0/students[i].length;//find average

System.out.printf("%.2f",avg);//print average by precison of two

System.out.println();

}

}

else if(choice==3)

{//caculate averag eby exams and print it

System.out.println("*** Average by Exam Number ***");

System.out.println("Exam Number\tAverage Score");

for(int i=0;i<maxExams;i++)

{

int sum=0,total=0;

for(int j=0;j<index;j++)

{

if(students[j].length>=i+1)

{

total++;

sum=sum+students[j][i];

}

}

double avg=sum*1.0/total;

System.out.print((i+1)+"\t");

System.out.printf("%.2f",avg);

System.out.println();

}

}

else if(choice ==4)

{//find iverall average

int sumtotal=0;

for(int i=0;i<index;i++)

{

int sum=0;

for(int j=0;j<students[i].length;j++)

{

sum=sum+students[i][j];

}

double avg=sum*1.0/students[i].length;

sumtotal+=avg;

}

double avgTotal=sumtotal*1.0/index;

System.out.println("Current class Average for all exams - "+avgTotal);

}

}while(choice!=5);

}

public static void main(String[] args) {

menu();

}

}

8 0
3 years ago
Other questions:
  • A type of memory that is expensive and therefore is often used only in cache memory applications.
    15·2 answers
  • Only those who perform music professionally can have a true appreciation for music. True False
    10·2 answers
  • Write a program that accepts 5 number and arrange them in ascending order​
    7·1 answer
  • It is illegal to have __________ emergency lights on your vehicle.
    6·2 answers
  • What is ‘Software Quality Assurance’?
    10·1 answer
  • Which media device uses the characteristic continuous?
    10·1 answer
  • 3. In a 32-bit CPU, the largest integer that we can store is 2147483647. Verify this with a
    12·1 answer
  • Review how to write a for loop by choosing the output of this short program.
    6·2 answers
  • if you put a drone on the charger at 8:12 and take a break at 10:03 how long is it on the charger. for
    7·1 answer
  • What is the optimal number of members for an Agile team?
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!