Your solution should for this assignment should consist of five (5)files:============================================== FuelGauge.h (class specification file)FuelGauge.cpp (class implementation file)Odometer.h (class specification file)Odometer.cpp (class implementation file)200_assign6.cpp (application program)=================================================★ For your sixth programming assignment, you will be implementing a program that uses two(2)classes that work together to simulate a car’s fuel gauge and odometer. The classes you will design are: TheFuelGaugeClass: This class will simulate a fuel gauge. Its responsibilities are↘To know the car’s current amount of fuel, in gallons.↘To report the car’s current amount of fuel, in gallons.↘To be able to increment the amount of fuel by 1 gallon. This simulates putting fuel in the car. (The car can hold a maximum of 15 gallons)↘To be able to decrement the amount of fuel by 1 gallon, if the amount of fuel is greater than 0 gallons. This simulates burning fuel as the car runs.TheOdometerClass: This class will simulate the car’s odometer. Its responsibilities are:↘To know the car’s current mileage.↘To report the car’s current mileage.↘To be able to increment the current mileage by 1 mile. The maximum mileage the odometer can store is 999,999 miles. When this amount is execeeded, the odometer resets the current mileage to 0.↘To be able to work with aFuelGaugeobject. It should decrease theFuelGaugeobject’s current amount of fuel by 1 gallon for every 24 miles traveled. (The car’s fuel economy is 24 miles per gallon)The FuelGaugeclass should have at least one constructor, and the appropriate member functions to get the number of gallons, increment the number of gallons, and decrement the number of gallons.★ The odometer class should have at least one constructor, and the appropriate member functions to get the mileage and increment the mileage (unfortunately you cannot decrement the mileage!).★ In the odometer class, you can have a member variable that is a pointer to a FuelGauge object. This is how you can establish a relationship between the two classes that allow them to work together. For every mile the car is driven, the odometer is increased by 1, and for every 24 miles the car is driven, the number of gallons is reduced by one.★ So in the Odometer class, one of the private member variables should be of type fuel gauge* (pointer to a FuelGauge object).★ Demonstrate the two classes by creating instances(objects)of each. Simulate filling the car up with fuel, and then run a loop that increments the odometer until the car runs out of fuel. During each loop iteration, print the car’s current mileage and amount of fuel.

Answers

Answer 1

Answer: provided in the explanation section

Explanation:

This was implemented in C++

Filename: Car.cpp

#include <iostream>

#include <iomanip>

#include <cstdlib>

#include "Odometer.h"

using namespace std;

int main()

{

  char response;

  do

  {

      FuelGuage* myFuel = new FuelGuage(6);

      int fuelLevel = myFuel->getFuel();

      cout << "Car gas level: " << fuelLevel << endl;

      cout << "Car is filling up" << endl;

      while(myFuel->getFuel() < 15)

      {

          myFuel->addFuel();

      }

      Odometer* car = new Odometer(myFuel, 999990);

      cout << "Car gas level: " << car->getFuelGuage()->getFuel() << endl;

      cout << "Car is off!" << endl;

      cout << "--------------------------" << endl;

      while(car->getFuelGuage()->getFuel() > 0)

      {

          car->addMile();

          int miles = car->getMileage();

          cout << "Mileage: " << setw(6) << miles << ", Fuel Level: " << car->getFuelGuage()->getFuel() << endl;

          cout<<"--------------------------------------------------------------"<<endl;

      }

      delete myFuel;

      delete car;

      cout << "Would you like to run the car again(Y/N)? ";

      cin >> response;

      system("cls||clear");

  } while(toupper(response) != 'N');

  return 0;

}

Filename: FuelGuage.cpp

#include "FuelGuage.h"

FuelGuage::FuelGuage()

{

  init();

}

FuelGuage::FuelGuage(int fuel)

{

  init();

  this->fuel = fuel;

}

FuelGuage::FuelGuage(const FuelGuage& copy)

{

  this->fuel = copy.fuel;

}

void FuelGuage::init()

{

  this->fuel = 0;

}

int FuelGuage::getFuel()

{

  return fuel;

}

void FuelGuage::addFuel()

{

  fuel++;

}

void FuelGuage::burnFuel()

{

  fuel--;

}

Filename:FuelGuage.h

#ifndef FUEL_GUAGE_H

#define FUEL_GUAGE_H

class FuelGuage

{

private:

  int fuel;

  void init();

public:

  FuelGuage();

  FuelGuage(int fuel);

  FuelGuage(const FuelGuage& copy);

  int getFuel();

  void addFuel();

  void burnFuel();

};

#endif

Filename : Odometer.cpp

#include "Odometer.h"

Odometer::Odometer()

{

  init();

}

Odometer::Odometer(FuelGuage* inFuel, int inMileage)

{

  init();

  this->fuel = new FuelGuage(*inFuel);

  this->mileage = inMileage;

  this->milesSinceAddingFuel = 0;

}

void Odometer::init()

{

  fuel = new FuelGuage();

  mileage = 0;

  milesSinceAddingFuel = 0;

}

FuelGuage* Odometer::getFuelGuage()

{

  return fuel;

}

int Odometer::getMileage()

{

  return mileage;

}

void Odometer::addMile()

{

  if(mileage < 999999)

  {

      mileage++;

      milesSinceAddingFuel++;

  }

  else

  {

      mileage = 0;

      milesSinceAddingFuel++;

  }

  if((milesSinceAddingFuel % 24) == 0)

  {

      fuel->burnFuel();

  }

}

void Odometer::resetMiles()

{

  milesSinceAddingFuel = 0;

}

Odometer::~Odometer()

{

  delete fuel;

}

Filename: Odometer.h

#ifndef ODOMETER_H

#define ODOMETER_H

#include "FuelGuage.h"

class Odometer

{

private:

  void init();

  int mileage;

  int milesSinceAddingFuel;

  FuelGuage* fuel;

public:

  Odometer();

  Odometer(FuelGuage* inFuel, int inMileage);

  FuelGuage* getFuelGuage();

  int getMileage();

  void addMile();

  void resetMiles();

  ~Odometer();

};

#endif


Related Questions

Mileage Calculator You are tasked with creating a mileage caclulator to calculate the amount of money that should be paid to employees. The mileage is computed as follows An amount of .25 for each mile up to 100 miles An amount of .15 for every mile above 100. So 115 miles would be (.25 * 100) (.15 * 15) This can all be coded using a mathematical solution but I want you to use an if / else statement. Here is how you are to implement it: If the total miles input is less than or equal to 100 then simply calculate the miles * .25 and output the amount otherwise compute the total amount for all miles mathematically. Input: Total number of miles Process: dollar amount owed for miles driven Output: Amount of money due

Answers

Answer:

mileage = float(input("Enter mileage: ")) if (mileage > 100):    amount = (mileage - 100) * 0.15 + 100 * 0.25 else:    amount = mileage * 0.25   print("Total amount: $" + str(amount))

Explanation:

The solution code is written in Python 3.

Firstly, prompt user to input a mileage (Line 1).

Next, create an if statement to check if a mileage greater than 100 (Line 3). If so, apply the formula to calculate amount with mileage above 100 (Line 4) otherwise,  calculate the amount just by multiplying the mileage by 0.25.

At last, print the total amount (Line 8).

3.22 LAB: Driving cost - methods Write a method drivingCost() with input parameters drivenMiles, milesPerGallon, and dollarsPerGallon, that returns the dollar cost to drive those miles. All items are of type double. If the method is called with 50 20.0 3.1599, the method returns 7.89975. Define that method in a program whose inputs are the car's miles/gallon and the gas dollars/gallon (both doubles). Output the gas cost for 10 miles, 50 miles, and 400 miles, by calling your drivingCost() method three times. Output each floating-point value with two digits after the decimal point, which can be achieved as follows: System.out.printf("%.2f", yourValue); The output ends with a newline. Ex: If the input is: 20.0 3.1599 the output is: 1.58 7.90 63.20 Your program must define and call a method: public static double drivingCost(double drivenMiles, double milesPerGallon, double dollarsPerGallon) Note: This is a lab from a previous chapter that now requires the use of a method.

Answers

Answer:

The java program for the given scenario is as follows.

import java.util.Scanner;

import java.lang.*;

public class Test

{

   //variables to hold miles per gallon and cost per gallon

   static double miles_gallon, dollars_gallon;

   public static void main(String[] args)

   {

       Scanner sc = new Scanner(System.in);

       System.out.print("Enter the car's mileage in miles per gallon: ");

       miles_gallon=sc.nextDouble();

       System.out.print("Enter the cost of gas in dollars per gallon: ");

       dollars_gallon=sc.nextDouble();

       System.out.printf("The cost of gas for 10 miles is $%.2f\n", drivingCost(10, miles_gallon, dollars_gallon));

       System.out.printf("The cost of gas for 50 miles is $%.2f\n", drivingCost(50, miles_gallon, dollars_gallon));

       System.out.printf("The cost of gas for 400 miles is $%.2f\n", drivingCost(400, miles_gallon, dollars_gallon));

   }

   //method to compute cost of gas

   public static double drivingCost(double drivenMiles, double milesPerGallon, double dollarsPerGallon)

   {

       double cost = ((drivenMiles/milesPerGallon)*dollarsPerGallon);

       return cost;

   }

}

OUTPUT

Enter the car's mileage in miles per gallon: 12

Enter the cost of gas in dollars per gallon: 23

The cost of gas for 10 miles is $19.17

The cost of gas for 50 miles is $95.83

The cost of gas for 400 miles is $766.67

Explanation:

1. Two double variables to hold user input for miles per gallon and cost of gas per gallon, are declared.

2. The variables are declared static, and at the class level (outside main()).

3. Inside main(), an object of Scanner class is created.

4. User input is taken for miles per gallon and cost of gas per gallon.

5. Next, the method, drivingCost() is called. This method takes three parameters - miles per gallon, cost of gas per gallon and miles driven. Based on these parameters and the given formula, the cost of gas is computed.

6. This value is then displayed to the user.

7. The method, drivingCost(), is called three times for 10 miles, 50 miles and 400 miles being driven.

8. The whole code is written inside a class since java is a purely object-oriented language.

9. The object of the class is not created since only a single class is used.

10. The program is saved as Test.java.

In this exercise we have to use the knowledge in computational language in JAVA to describe a code that best suits, so we have:

The code can be found in the attached image.

To make it simpler we can write this code as:

import java.util.Scanner;

import java.lang.*;

public class Test

{

  //variables to hold miles per gallon and cost per gallon

  static double miles_gallon, dollars_gallon;

  public static void main(String[] args)

  {

      Scanner sc = new Scanner(System.in);

      System.out.print("Enter the car's mileage in miles per gallon: ");

      miles_gallon=sc.nextDouble();

      System.out.print("Enter the cost of gas in dollars per gallon: ");

      dollars_gallon=sc.nextDouble();

      System.out.printf("The cost of gas for 10 miles is $%.2f\n", drivingCost(10, miles_gallon, dollars_gallon));

      System.out.printf("The cost of gas for 50 miles is $%.2f\n", drivingCost(50, miles_gallon, dollars_gallon));

      System.out.printf("The cost of gas for 400 miles is $%.2f\n", drivingCost(400, miles_gallon, dollars_gallon));

  }

  //method to compute cost of gas

  public static double drivingCost(double drivenMiles, double milesPerGallon, double dollarsPerGallon)

  {

      double cost = ((drivenMiles/milesPerGallon)*dollarsPerGallon);

      return cost;

  }

}

See more about JAVA at brainly.com/question/19705654

What are keyboards that include all the keys found on a typical virtual keyboard, as well as extra keys, such as function and navigation keys

Answers

Answer:

multimedia keyboard i think

Explanation:

The keyboards that include all the keys found on a typical virtual keyboard including function and navigation keys are called;

Laptops

A virtual keyboard is one that appears only when we require it and then goes away after we are done using it. Due to the nature of them, they occupy a small space. Examples of these virtual keyboards are the keyboards in touch screen mobile phones as well as tablets. Also, there are some computer operating systems that support virtual keyboards such as Windows 10.

Now, it is pertinent to know that virtual keyboards don't require physical keys to operate and also they don't possess the function and navigation keys that traditional keyboards have.

The only other unit that has a keyboard that possesses the function and navigation keys are Laptops.

Read more at; https://brainly.in/question/11722276

Implement the Dining Philosophers problem (described on pages 167-170 in the textbook (chapter 2.5.1)). Create a Graphical User Interface - showing which philosopher is eating, and which is waiting/thinking at any given time. Show the forks. Use Java programming language for this project.

Answers

Answer: Provided in the explanation section

Explanation:

class philosopher extends Thread

{

public void run()

{

diningps.count++;

philosopher(diningps.count);

}

public void philosopher(int i)

{

take_forks(i);

System.out.println(i+"philosopher Eating");

put_forks(i);

}

public void take_forks(int i)

{

while(diningps.mutex<=0)

{

System.out.println(i+"philosopher has to be wait while other philosopher in testing");

}

diningps.state[i]="HUNGRY";

test(i);

diningps.mutex=1;

while(diningps.S[i]<=0)

{

System.out.println(i+"philosopher has to be wait while his left or right side philosopher eating.");

}

}

public void put_forks(int i)

{

while(diningps.mutex<=0)

{

System.out.println(i+"philosopher has to be wait while other philosopher in testing");

}

diningps.state[i]="THINK";

test((i+4)%5);

test((i+1)%5);

diningps.mutex=1;

}

public void test(int i)

{

if(diningps.state[i]=="HUNGRY" && diningps.state[(i+4)%5]!="EAT" && diningps.state[(i+1)%5]!="EAT")

{

diningps.state[i]="EAT";

diningps.S[i]=1;

}

}

}

class diningps

{

static int mutex=1;

static int S[]={0,0,0,0,0};

static String state[]={"THINK","THINK","THINK","THINK","THINK"};

static int count=-1;

public static void main(String ar[])

{

philosopher ob=new philosopher();

philosopher ob1=new philosopher();

philosopher ob2=new philosopher();

philosopher ob3=new philosopher();

philosopher ob4=new philosopher();

ob.start();

ob1.start();

ob2.start();

ob3.start();

ob4.start();

}

}

cheers i hope this helped !!

Create a class to represent the locker and another class to represent the combination lock. The Locker class will include an attribute that is of type CombinationLock. Each class must include a constructor with no input argument and also a constructor that requires input arguments for all attributes. Each class must include the appropriate set and get methods. Each class must include a method to print out all attributes.

Answers

Answer:

Class Locker

public class Locker {  

int lockno;  

String student;

int booksno;

private CombinationLock comblock = new CombinationLock();

public Locker() {

 lockno = 0;

 student= "No Name";

 booksno = 0;

 comblock.reset();  }

public Locker(int lockno, String student, int booksno,

  CombinationLock comblock) {

 super();

 this.lockno= lockno;

 this.student= student;

 this.booksno= booksno;

 this.comblock= comblock;  }

public int getLockNo() {

 return lockno;   }

public void setLockNo(int lockno) {

 this.lockno= lockno;  }

public String getName() {

 return student;  }

public void setName(String student) {

 this.student = student;  }

public int getBooksNumber() {

 return booksno;   }

public void setBooksNumber(int booksno) {

 this.booksno= booksno;  }

public String getComblock() {

 return comblock.toString();  }

public void setComblock(int no1, int no2, int no3) {

 this.comblock.setNo1(no1);  

 this.comblock.setNo2(no2);  

 this.comblock.setNo3(no3);   }

public String printValues() {

 return "Locker [lockno=" + lockno+ ", student="

   + student+ ", booksno=" + booksno

   + ", comblock=" + comblock+ "]";  }  }

The class Locker has attributes lockno for lock number, student for students names and bookno for recording number of books. Locker class also an attribute of type CombinationLock named as comblock. Locker class includes a constructor Locker() with no input argument and also a constructor Locker() that requires input arguments for all attributes lockno, student, booksno and comblock. super() calls on immediate parent class constructor. Class Locker contains the following set methods: setLockNo, setName, setBooksNumber and setComblock. Class Locker contains the following get methods: getLockNo, getName, getBooksNumber and getComblock. printValues() method displays the values of attributes.

Explanation:

Class CombinationLock

*/ CombinationLock has attributes no1, no2 and no3. It has a  constructor CombinationLock() with no input argument and also a constructor CombinationLock() that requires input arguments for attributes no1 no2 and no3. Class CombinationLock contains the following set methods: setNo1, setNo2 and setNo3. The class contains the following get methods: getNo1, getNo2 and getNo3. The class includes a method printValues() to print out all attributes.

public class CombinationLock {

int no1;

int no2;

int no3;  

public CombinationLock() {

 this.no1= 0;

 this.no2= 0;

 this.no3= 0;   }  

public CombinationLock(int no1, int no2, int no3) {

 super();

 this.no1= no1;

 this.no2= no2;

 this.no3= no3;  }

 

public int getNo1() {

 return no1;  }

public void setNo1(int no1) {

 this.no1= no1;  }

public int getNo2() {

 return no2;  }

public void setNo2(int no2) {

 this.no2= no2;  }

public int getNo3() {

 return no3;  }

public void setNo3(int no3) {

 this.no3= no3;  }

 

public void reset() {

 this.no1=0;

 this.no2=0;

 this.no3=0;  }

public String printValues() {

 return "CombinationLock [no1=" + no1+ ", no2=" +  no2

   + ", no3=" + no3+ "]";  }  }

Imagine a TCP session over wireless where the congestion window is fixed at 5 segments (congestion control is turned off and no fast retransmits). Segments may get lost but are not reordered. The receiver has an infinite buffer and it sends an acknowledgment as soon as it receives a segment, i.e., acknowledgments are not deferred. Similarly, the sender transmits a segment as soon as it is allowed to. Each segment carries 1000 bytes and the time to transmit a segment is 2 ms. Assume that transmission of ACK takes negligible time. Note that the retransmission timer for a segment is started after the last bit of the segment is sent. Assume Go-Back-5, and accumulative ACK is used.
Suppose two data segments with byte sequence numbers 3000 and 15000 are lost once during the transmission. How many segments get retransmitted under each of the following conditions?
A. Round trip time = 100 ms, Timeout = 101 ms
B. Round trip time = 100 ms, Timeout = 152 ms

Answers

Answer:

a) 179 segments

b) 28 segments

Explanation:

Given data :

A) Round trip time = 100 ms, Timeout = 101 ms

number of segments  for round trip = 3000/100 = 30 segments

number of segments for timeout = 15000/100 = 150 segments

total number of segments = 150 + 30 = 180

segments that get re-transmitted under A

Total segments - timeout = 180 - 101 = 179 segments

B) Round trip = 100 ms Timeout = 152 ms

number of segments for round trip = 3000/100 = 30 segments

number of segments for timeout = 15000/100 = 150 segments

total segments = 150 + 30 = 180

segments that get re-transmitted under B

total segments - timeout = 180 - 152 = 28 segments

When we convert an automaton to a regular expression, we need to build expression not go through certain other states. Below is a nondeterministic finite automaton with three states. For each of the six orders of the three states, find s for the labels along paths from one state to another state that do regular expressions that give the set of labels along all paths from the first state to the second state that never go through the third state. Then identify one of these expressions from the list of choices below.
a) (10)*1 represents the paths from C to B that do not go through A.
b) 1 represents the paths from C to B that do not go through A.
c) (01)+ represents the paths from B to C that do not go through A
d) 1 represents the paths from A to B that do not go through C.

Answers

Answer: Provided in the explanation section

Explanation:

The below explanation will help to make this question simple to understanding.

For the questions presented, this analysis surfaces,

⇒ a) (10)*1 in this path we can go through A for C to B as 1010 exist from C to A then B also.

i.e. Option A is wrong , there is transition from c to A with 1.

b) 0 represent the path from B to A and from B to C also. So this is also not a solution.

i.e. Option B is wrong with input 1 there is path to both A and B from c

c) (1+11)0)*1 in this path for cover the 1+11 we have to go in two paths one is only 1 and second is 11. So 11 is the path which goes through the A.

i.e. Option c is wrong , with input 0 there is path to c input symbol 1 is not required

d) (01)+ is correct because we have + sign here not * so it not executes multiple times execute only 1 more time. So it is the path from B to C that does not through A.

cheers i hope this helped !!

A drawback of using observation as a data collection method is that:_______
a. it is inaccurate in measuring overt behavior.
b. it cannot be used to study cross-cultural differences.
c. it is appropriate only for frequently occurring behaviors.
d. it cannot be used to collect sensitive data about respondents.

Answers

Answer:

The answer is d, because it is not reliable in the sense that it can be used for important and sensitive information when your collecting data.

Riding a motorcycle on the street is not for everyone because: A. Highway signs are more difficult for motorcyclists to read B. Some people have difficulty managing risk C. All motorcycles are not the same D. Everyone can ride a bicycle

Answers

Answer:

Option B:

Some people have a difficulty in managing risks

Explanation:

Riding a motorcycle is a lot riskier than driving a car. This is because motorcyclists are exposed, and any accident that occurs will most likely lead to bodily harm to the rider.

Some individuals, have problems managing such risks, and cannot comfortably control the motorbike on the highway because of the number of cars speeding by.

Such individuals are not expected to be riding as this lack of confidence when riding on the highways can lead to accidents.

The first programming project involves writing a program that computes the minimum, the maximum and the average weight of a collection of weights represented in pounds and ounces that are read from an input file. This program consists of two classes. The first class is the Weight class, which is specified in integer pounds and ounces stored as a double precision floating point number. It should have five public methods and two private methods:A public constructor that allows the pounds and ounces to be initialized to the values supplied as parameters.A public instance method named lessThan that accepts one weight as a parameter and returns whether the weight object on which it is invoked is less than the weight supplied as a parameter.A public instance method named addTo that accepts one weight as a parameter and adds the weight supplied as a parameter to the weight object on which it is invoked. It should normalize the result.A public instance method named divide that accepts an integer divisor as a parameter. It should divide the weight object on which the method is invoked by the supplied divisor and normalize the result.A public instance toString method that returns a string that looks as follows: x lbs y oz, where x is the number of pounds and y the number of ounces. The number of ounces should be displayed with three places to the right of the decimal.A private instance method toOunces that returns the total number of ounces in the weight object on which is was invoked.A private instance method normalize that normalizes the weight on which it was invoked by ensuring that the number of ounces is less than the number of ounces in a pound.Both instance variable must be private. In addition the class should contain a private named constant that defines the number of ounces in a pound, which is 16. The must not contain any other public methods.The second class should be named Project1. It should consist of the following four class (static) methods.The main method that reads in the file of weights and stores them in an array of type Weight. It should then display the smallest, largest and average weight by calling the remaining three methods. The user should be able to select the input file from the default directory by using the JFileChooser class. The input file should contain one weight per line. If the number of weights in the file exceeds 25, an error message should be displayed and the program should terminate.A private class method named findMinimum that accepts the array of weights as a parameter together with the number of valid weights it contains. It should return the smallest weight in that array.A private class method named findMaximum that accepts the array of weights as a parameter together with the number of valid weights it contains. It should return the largest weight in that array.A private class method named findAverage that accepts the array of weights as a parameter together with the number of valid weights it contains. It should return the average of all the weights in that array.Be sure to follow good programming style, which means making all instance variables private, naming all constants and avoiding the duplication of code. Furthermore you must select enough different input files to completely test the program.Java programmingThe text file could not be attached but it looks like this:Year,Weight in Lbs,Weight Loss Rate1994,713.6,91995,684.5,8.21996,636.6,7.41997,611,6.81998,567.6,6.31999,523,5.72000,506.5,5.52001,504.5,5.62002,494.4,5.62003,475.8,5.72004,463.2,5.52005,469,5.62006,479.3,5.82007,471.8,5.72008,458.6,5.42009,431.9,52010,404.5,4.82011,387.1,4.72012,387.8,4.72013,367.9,4.5please tell me what to do? How to get the problem done.

Answers

Answer:

yoooooooooooooooooooooooo

Explanation:

lrmgkrmbm mrm g

Suppose that you are given the following partial data segment, which starts at address 0x0700 : .data idArray DWORD 1800, 1719, 1638, 1557, 1476, 1395, 1314, 1233, 1152, 1071, 990 u DWORD LENGTHOF idArray v DWORD SIZEOF idArray What value does EAX contain after the following code has executed? (Ignore the .0000 that Canvas sticks on the end) mov esi, OFFSET idArray mov eax, [esi+0*TYPE idArray]

Answers

Answer:

The value EAX contain after the code has been executed is 1233

Explanation:

Solution

Now,

The below instruction describes the MOV operation.

The MOV esi, OFFSET idArray .

It shows the movement, the offset value of the idArray in the esi.

Thus,

Follow the below instruction

MOV eax, [esi+7*TYPE idArray]

It will move the address of the idArray at that position into eax.

Value at the 7th position is moved to eax.

Therefore, the value at eax will be 1233.

Write an if-else statement with multiple branches. If year is 2101 or later, print "Distant future" (without quotes). Otherwise, if year is 2001 or greater, print "21st century". Otherwise, if year is 1901 or greater, print "20th century". Else (1900 or earlier), print "Long ago". Sample output with input: 1776 Long ago

Answers

Answer:

year = int(input("Enter a year: "))

if year >= 2101:

   print("Distant future")

elif year >= 2001:

   print("21st century")

elif year >= 1901:

   print("20th century")

else:

   print("Long ago")

Explanation:

*The code is in Python.

Ask the user to enter a year

Use if-else statement to check the year and print the appropriate message given for each condition. If year is greater than or equal to 2101, print "Distant future". If year is greater than or equal to 2001, print "21st century". If year is greater than or equal to 1901, print "20th century". Otherwise, print "Long ago".

Consider the class Money declared below. Write the member functions declared below and the definition of the overloaded +. Modify the class declaration and write the definitions that overload the stream extraction and stream insertion operators >> and << to handle Money objects like $250.99
Write a short driver main() program to test the overloaded operators +, << and >> class Money { public: friend Money operator +(const Money& amountl, const Money& amount2) Money(); // constructors Money( int dollars, int cents); // set dollars, cents double get_value() const; void printamount();// print dollars and cents like $12.25 private: int all_cents; // all amount in cents };

Answers

Answer: Provided in the explanation section

Explanation:

#include<iostream>

using namespace std;

class Money{

  private:

      int all_cents;

  public:

      Money();

      double get_value() const;

      Money(int,int);

      void printamount();

      friend Money operator+(const Money&, const Money&);

      friend ostream& operator<<(ostream&, const Money&);

      friend istream& operator>>(istream&, Money&);

};

Money::Money(){all_cents=0;}

double Money::get_value() const{return all_cents/100.0;}

Money::Money(int dollar ,int cents){

  all_cents = dollar*100+cents;

}

void Money::printamount(){

  cout<<"$"<<get_value()<<endl;

}

Money operator+(const Money& m1, const Money& m2){

  int total_cents = m1.all_cents + m2.all_cents;

  int dollars = total_cents/100;

  total_cents %=100;

  return Money(dollars,total_cents);

}

ostream& operator<<(ostream& out, const Money& m1){

  out<<"$"<<m1.get_value()<<endl;

  return out;

}

istream& operator>>(istream& input, Money& m1){

  input>>m1.all_cents;

  return input;

}

int main(){

 

  Money m1;

  cout<<"Enter total cents: ";

  cin>>m1;

  cout<<"Total Amount: "<<m1;

 

  Money m2 = Money(5,60);

  Money m3 = Money(4,60);

  cout<<"m2 = ";m2.printamount();

  cout<<"m3 = ";m3.printamount();

  Money sum = m2+m3;

  cout<<"sum = "<<sum;

 

}

cheers i hope this helped !!

On a piano, a key has a frequency, say f0. Each higher key (black or white) has a frequency of f0 * rn, where n is the distance (number of keys) from that key, and r is 2(1/12). Given an initial key frequency, output that frequency and the next 4 higher key frequencies.

Answers

Answer:

The programming language is not stated; so, I'll solve this question using Java programming language

Comments are used for explanatory purpose

//Begin of Program

import java . util.*;

import java. math . RoundingMode;

import java . text . DecimalFormat;

public class keyfreq

{

private static DecimalFormat df = new DecimalFormat("0.00");

public static void main(String [] args)

{

 Scanner input = new Scanner(System.in);

 //Declare variable

 float f0;

//Prompt user for input

System.out.print("Enter Initial Key Frequency: ");

f0 = input.nextFloat();

//Initialize number of keys

int numkey = 1;

//Print first key frequency

System.out.print("Key Frequencies: " + df.format(f0)+" ");  

while(numkey<=4)

{

 //Calculate next frequency

 f0*= Math.pow(2,(1.0/12.0));

 //Print Frequency

 System.out.print(df.format(f0)+" ");  

  //Iterate to next frequency

 numkey++;

}

}

}

//End of Program

Explanation:

See Comments in the above program

See Attachment for source file

Rewrite this method so that it avoids the use of a return statement:
void divisionQuestion()
{
int x, y;
x = (int)random(-10, 11);
y = (int)random(-10, 11);
if (y == 0)
{
println("Sorry we chose 0 for the denominator");
return;
}
else
println(x + " divided by " + y + " is " + x / y);
}

Answers

Sorry we chose 0 for the denominator

what are the reasonsfor documenting business rules​

Answers

Answer:

This is because when there is a mistake, misunderstanding or trouble and one need's evidence, the documented business rule will be available as your evidence.

Explanation:

Sorry if I'm wrong hope it helps

The part of a computer that we can touch and feel: (one word answer)

Answers

Answer:

hardware

Explanation:

hardware is the part where we can touch and feel while software ,we cant

Answer:

keyboard

Explanation:

): A cable has a bandwidth of 3000 Hz assigned for data communication. The SNR is 3162. How many signal levels do we need?

Answers

Answer:

[tex]L=2^{25830}[/tex] is the correct answer .

Explanation:

bandwidth = 3000 Hz

SNR =3162

We know that

[tex]bitrate = bandwidth * log2(1 + SNR)[/tex]

Putting the value of bandwidth and SNR in the given equation .

[tex]bitrate = 3000 * log_{2} ^\ (1 + 3162) \\\\birate = 3000 * log_{2} ^\ {3163} \\\\birate =3000 * 11.\ 6\\\\bitrate=\ 34860 bps[/tex]

Now using the formula

[tex]BitRate = 2 * Bandwidth * log_{2} (L)[/tex]

Putting the value of bitRate and bandwidth we get

[tex]34860=2\ * 3000\ * \ log_{2} (L)\\34860=6000 * \ log_{2} (L)[/tex]

[tex]31860-6000=log_2L\\25830=log_2L\\L=2^{25830}[/tex]

Determining the Services Running on a Network Alexander Rocco Corporation has multiple OSs running in its many branch offices. Before conducting a penetration test to determine the network’s vulnerabilities, you must analyze the services currently running on the network. Bob Kaikea, a member of your security team who’s experienced in programming and database design but weak in networking concepts, wants to be briefed on network topology issues at Alexander Rocco Corporation. Write a memo to Bob summarizing port numbers and services that run on most networks. The memo should discuss the concepts of well-known ports and give a brief description of the most commonly used ports: 20, 21, 23, 25, 53, and 110. Complete your mini-case projects in a Microsoft Word document (or any other text editor) and submit the completed work as instructed below. Remember - papers need to be in APA format with Title page.

Answers

Answer: provided in the explanation section

Explanation:

 Network’s vulnerabilities:

           Vulnerability is a weak spot in your network that might be exploited by a security threat. Risks are the potential consequences and impacts of unaddressed vulnerabilities. In other words, failing to do Windows Updates on your Web server is vulnerability.

           Regularly scheduled network vulnerability scanning can help an organization identify weaknesses in their network security before the bad guys can mount an attack. The goal of running a vulnerability scanner or conducting an external vulnerability assessments is to identify devices on your network that are open to known vulnerabilities without actually compromising your systems.

           The overall objective of a Vulnerability Assessment is to scan, investigate, analyze and report on the level of risk associated with any security vulnerabilities discovered on the public, internet-facing devices and to provide your organization with appropriate mitigation strategies to address those discovered vulnerabilities.

         

Network topology issues:

Coverage Topology

           Coverage problem reflects how well an area is monitored or tracked. The coverage and connectivity problems in networks have received considerable attention in the research community in recent years

 

Geographic routing

           Geographic routing uses geographic and topological information of the network to achieve optimal routing schemes with high routing efficiency and low power consumption

Port Numbers

           Port Numbers While IP addresses determine the physical endpoints of a network connection, port numbers determine the logical endpoints of the connection. Port numbers are 16-bit integers with a useful range from 1 to 65535.

Port numbers are assigned by an organization called IANA and ports are allocated to various needs to avoid confusion.

Ports are classified into 3 main categories.

Well Known Ports (Port numbers 0 - 1023)

           In a client-server application, the server usually provides its service on a well-known port number. Well-known port numbers are a subset of the numbers which are assigned to applications. According to RFC1700 [5], well-known port numbers are managed by the Internet Assigned Numbers Authority (IANA). They used to be in the range from 1 to 255, but in 1992 the range was increased up to 1023.

Registered Ports (Port numbers1024 - 49151)

Such ports are used by programs run by users in the system.

           In addition to the well-known ports below 1024 there are more port numbers assigned to applications but are located anywhere from 1024 to 65535.

Private or Dynamic Ports (Port numbers 49152 - 65535)

           Private ports are not assigned for any specific purpose.

         

Discuss the concepts of well-known ports and give a brief description of the most commonly used ports: 20, 21, 23, 25, 53, and 110.

Commonly Used Port Numbers

The following port numbers are unofficial list of commonly used for linux/unix based servers.

         

20&21               TCP                FTP (File server protocol)

           FTP is one of the most commonly used file transfer protocols on the Internet and within private networks. An FTP server can easily be set up with little networking knowledge and provides the ability to easily relocate files from one system to another. FTP control is handled on TCP port 21 and its data transfer can use TCP port 20 as well as dynamic ports depending on the specific configuration.

23                   TCP/UDP          Telnet

           Telnet is the primary method used to manage network devices at the command level. Unlike SSH which provides a secure connection, Telnet does not, it simply provides a basic unsecured connection. Many lower level network devices support Telnet and not SSH as it required some additional processing. Caution should be used when connecting to a device using Telnet over a public network as the login credentials will be transmitted in the clear.

25                   TCP/UDP         SMTP   (for sending outgoing emails)

           SMTP is used for two primary functions, it is used to transfer mail (email) from source to destination between mail servers and it is used by end users to send email to a mail system.

53         TCP/UDP        DNS Server (Domain name service for DNS request)

           The DNS is used widely on the public internet and on private networks to translate domain names into IP addresses, typically for network routing. DNS is hieratical with main root servers that contain databases that list the managers of high level Top Level Domains (TLD) (such as .com). T

110             TCP                 POP3 (For receiving emails)

           POP version 3 is one of the two main protocols used to retrieve mail from a server. POP was designed to be very simple by allowing a client to retrieve the complete contents of a server mailbox and then deleting the contents from the server.

We have a combinatorial logic function that can be decomposed into three steps each with the indicated delay with a resulting clock speed of 5.26 GHz.
1. 65ps
2. 45ps
3. 60ps
4. Reg 20ps
Assume we further pipeline this logic by adding just one additional register between the first two or last two stages of combinatorial logic. What would be the highest resulting clock speed we could achieve in GHz?
We have a combinatorial logic function that can be decomposed into three steps each with the indicated delay with a resulting clock speed of 4.76 GHz.
1. 65ps
2. 55ps
3. 70ps
4. Reg 20ps
Assume we further pipeline this logic by adding just one additional register between the first two or last two stages of combinatorial logic. What would be the highest resulting clock speed we could achieve in GHzi?

Answers

Answer:

1.    11.77 GHz

2.   11.11  GHz

Explanation:

1.

From the given information;

the highest resulting clock speed we could achieve in GHz is calculated as follows:

Using the formula:

highest resulting clock speed = 1/max (stage,stage,stage,stage) + register delay)

highest resulting clock speed = 1/max(65ps, 45ps, 60 ps) + 20ps)

highest resulting clock speed = 1/(65 + 20)ps

highest resulting clock speed =  1/85 ps

highest resulting clock speed = 0.01176470588  × 10¹² Hz

highest resulting clock speed = 1.17647059 × 10¹⁰ Hz

highest resulting clock speed =  1.177 × 10¹⁰ Hz

To Ghz; we have:

highest resulting clock speed = (1.177 × 10¹⁰/10⁹ )GHz

highest resulting clock speed = 11.77 Ghz

2.

Using the same formula from above;

highest resulting clock speed = 1/max(65ps, 55ps, 70 ps) + 20ps)

highest resulting clock speed = 1/(70 + 20)ps

highest resulting clock speed =  1/90 ps

highest resulting clock speed = 0.01111111111  × 10¹² Hz

highest resulting clock speed = 1.111111111  × 10¹⁰ Hz

highest resulting clock speed =  1.111 × 10¹⁰ Hz

To Ghz; we have:

highest resulting clock speed = (1.111 × 10¹⁰/10⁹ )GHz

highest resulting clock speed = 11.11 Ghz

In this exercise we have to calculate the delay time and the time to archive something, so we have that these times will be:

1) 11.77 GHz

2) 11.11  GHz

1) First we will use the knowledge to calculate the delay, so the formula can be used is:

[tex]HRCS = 1/max (stage,stage,stage,stage) + register delay)\\HRCS = 1/max(65ps, 45ps, 60 ps) + 20ps)\\HRCS = 1/(65 + 20)ps\\HRCS= 1/85 ps\\HRCS = 0.01176470588* 10^{12}Hz\\HRCS = 1.17647059 * 10^{10} Hz\\HRCS = 1.177 * 10^{10} HZ\\HRCS = 11.77 Ghz[/tex]

2) through the first formula we can also calculate the time for the speed of archiving, like this:

[tex]HRCS = 1/max(65ps, 55ps, 70 ps) + 20ps)\\HRCS = 1/(70 + 20)ps\\HRCS = 1/90 ps\\HRCS = 0.01111111111 * 10^{12} Hz\\HRCS = 1.111111111 * 10^{10} Hz\\HRCS = 11.11 Ghz[/tex]

See  more about GHZ at brainly.com/question/13112545

Write MATLAB script programs to perform the following conversions, taking a value in SI units as the input argument and returning the value to US Customary Units.

a. Length: Centimeters to inches.
b. Temperature: °C to °F
c. Force: Newton to Pound-forced.
d. Speed: Meters per second to miles per hour

Answers

The answer most likely C

Look at the following array definition:

const int numbers[SIZE] = { 18, 17, 12, 14 };
Suppose we want to pass the array to the function processArray in the following manner:

processArray(numbers, SIZE);
Which of the following function headers is the correct one for the processArray function?

a. void processArray(const int *arr, int size)
b. void processArray(int * const arr, int size)

Answers

Answer:

The answer is void process Array (int arr {}, int n)

Explanation:

Solution

From the given question, the right choice answer i not listed  here.

However this is the right answer choice stated as follows: void process Array (int arr {}, int n)

The size of this array is not fixed. we need to pass or move the array as the second  argument to the function.

The option a and b is wrong.

Consider the following method, sumRows, which is intended to traverse all the rows in the two-dimensional (2D) integer array num and print the sum of all the elements in each row.
public static void sumRows(int[][] num)
{
for (int[] r : num)
{
int sum = 0;
for (int j = 0; j < num.length; j++)
{
sum += r[j];
}
System.out.print(sum + " ");
}
}
For example, if num contains {{3, 5}, {6, 8}}, then sumRows(num) should print "8 14 ".
The method does not always work as intended. For which of the following two-dimensional array input values does sumRows NOT work as intended?
A. {{10, -18}, {48, 17}}
B. {{-5, 2, 0}, {4, 11, 0}}
C. {{4, 1, 7}, {-10, -11, -12}}
D. {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}
E. {{0, 1}, {2, 3}}

Answers

Answer:

Option C: {{4, 1, 7}, {-10, -11, -12}}

Explanation:

There is a logical error in the inner loop.

for (int j = 0; j < num.length; j++)

It shouldn't be "j < num.length" as the iteration of the inner loop will be based on the length of the row number of the two dimensional array. The inner loop is expected to traverse through the every column of the same row in the two dimensional array and sum up the number. To fix this error, we can change it to

for (int j = 0; j < r.length; j++)

The sumRows method adds up all elements in each row, and prints the calculated sum.

The sumRows method would not work for input values (c) {{4, 1, 7}, {-10, -11, -12}}

In the inner loop of the sumRows method, we have

for (int j = 0; j < num.length; j++)

The above loop iterates from 0 to one less than the number of columns in the array.

Take for instance, {{10, -18}, {48, 17}} has 2 rows, and 2 columns.

So, the iteration would be for elements at indices 0 and 1.

However, the array {{4, 1, 7}, {-10, -11, -12}} has 3 rows and 2 columns

So, the iteration would be for elements at indices 0 and 1; leaving the element at index 2

Hence, the sumRows method would not work for input values (c) {{4, 1, 7}, {-10, -11, -12}}

Read more about methods at:

https://brainly.com/question/23052617

g You are looking to rob a jewelry store. You have been staking it out for a couple of weeks now and have learned the weights and values of every item in the store. You are looking to get the biggest score you possibly can but you are only one person and your backpack can only fit so much. Write a function called get_best_backpack(items: List[Item], max_capacity: int) -> "List[Item]" that accepts a list of Items as well as the maximum capacity that your backpack can hold and returns a list containing the most valuable items you can take that still fit in your backpack.

Answers

Answer:

A python code (Python recursion) was used for this given question

Explanation:

Solution

For this solution to the question, I am attaching code for these 2 files:

item.py

code.py

Source code for item.py:

class Item(object):

def __init__(self, name: str, weight: int, value: int) -> None:

  self.name = name

  self.weight = weight

  self.value = value

def __lt__(self, other: "Item"):

  if self.value == other.value:

if self.weight == other.weight:

  return self.name < other.name

else:

  return self.weight < other.weight

  else:

   return self.value < other.value

def __eq__(self, other: "Item") -> bool:

  if is instance(other, Item):

return (self.name == other.name and

self.value == other.value and

self.weight == other.weight)

  else:

return False

def __ne__(self, other: "Item") -> bool:

  return not (self == other)

def __str__(self) -> str:

  return f'A {self.name} worth {self.value} that weighs {self.weight}'

Source code for code.py:

#!/usr/bin/env python3

from typing import List

from typing import List, Generator

from item import Item

'''

Inductive definition of the function

fun3(0) is 5

fun3(1) is 7

fun3(2) is 11

func3(n) is fun3(n-1) + fun3(n-2) + fun3(n-3)

Solution 1: Straightforward but exponential

'''

def fun3_1(n: int) -> int:

result = None

if n == 0:

result = 5 # Base case

elif n == 1:

result = 7 # Base case

elif n == 2:

result = 11 # Base case

else:

result = fun3_1(n-1) + fun3_1(n-2) + fun3_1(n-3) # Recursive case

return result

''

Solution 2: New helper recursive function makes it linear

'''

def fun3(n: int) -> int:

''' Recursive core.

fun3(n) = _fun3(n-i, fun3(2+i), fun3(1+i), fun3(i))

'''

def fun3_helper_r(n: int, f_2: int, f_1: int, f_0: int):

result = None

if n == 0:

result = f_0 # Base case

elif n == 1:

result = f_1 # Base case

elif n == 2:

result = f_2 # Base case

else:

result = fun3_helper_r(n-1, f_2+f_1+f_0, f_2, f_1) # Recursive step

return result

return fun3_helper_r(n, 11, 7, 5)

''' binary_strings accepts a string of 0's, 1's, and X's and returns a generator that goes through all possible strings where the X's

could be either 0's or 1's. For example, with the string '0XX1',

the possible strings are '0001', '0011', '0101', and '0111'

'''

def binary_strings(string: str) -> Generator[str, None, None]:

def _binary_strings(string: str, binary_chars: List[str], idx: int):

if idx == len(string):

yield ''.join(binary_chars)

binary_chars = [' ']*len(string)

else:

char = string[idx]

if char != 'X':

binary_chars[idx]= char

yield from _binary_strings(string, binary_chars, idx+1)

else:

binary_chars[idx] = '0'

yield from _binary_strings(string, binary_chars, idx+1)

binary_chars[idx] = '1'

yield from _binary_strings(string, binary_chars, idx+1)

binary_chars = [' ']*len(string)

idx = 0

yield from _binary_strings(string, binary_chars, 0)

''' Recursive KnapSack: You are looking to rob a jewelry store. You have been staking it out for a couple of weeks now and have learned

the weights and values of every item in the store. You are looking to

get the biggest score you possibly can but you are only one person and

your backpack can only fit so much. Write a function that accepts a

list of items as well as the maximum capacity that your backpack can

hold and returns a list containing the most valuable items you can

take that still fit in your backpack. '''

def get_best_backpack(items: List[Item], max_capacity: int) -> List[Item]:

def get_best_r(took: List[Item], rest: List[Item], capacity: int) -> List[Item]:

if not rest or not capacity: # Base case

return took

else:

item = rest[0]

list1 = []

list1_val = 0

if item.weight <= capacity:

list1 = get_best_r(took+[item], rest[1:], capacity-item.weight)

list1_val = sum(x.value for x in list1)

list2 = get_best_r(took, rest[1:], capacity)

list2_val = sum(x.value for x in list2)

return list1 if list1_val > list2_val else list2

return get_best_r([], items, max_capacity)

Note: Kindly find an attached copy of the code outputs for python programming language below

Print Job Cost Calculator (10 points)
Filename: PrintJobCost.java
Write a program that asks the user to enter a string that encodes a print job. The string has this format:
"Papersize ColorType Count"
PaperSize, colorType and count are separated by exactly one space.
The first part of the string represents the size of the paper used:
Paper Size (string) Cost per Sheet ($)
"Letter" 0.05
The second part of the string represents the color of the printing. This cost is added to the cost of the paper itself
Printing Type (string) Cost per Sheet($)
"Grayscale" 0.01
"Colored" 0.10
The program computes and prints the total cost of the current printing job to two decimal places to the right of the decimal point.
Note: You may assume that all function arguments will be valid (e.g., no negative values, invalid paper sizes, etc.)
Several example runs are given below.
t Enter print job info: Legal Grayscale 44 Print job cost: $3.08 C Enter print job info: A4 Colored 4 Print job cost: $0.62 t Enter print job info: Letter Grayscale 32 Print job cost: $1.9

Answers

Answer: Provided in the explanation section

Explanation:

Provided is the code  to run this program

Source Code:

import java.util.Scanner;

class PrintJobCost

{

  public static void main(String[] args) {

      Scanner input=new Scanner(System.in);

      System.out.print("Enter print job info:");

      String info=input.nextLine();

      String size="",type="";

      int count=0,i=0,len=info.length();

      double cost=0.0;

      while(info.charAt(i)!=' '){

          size=size+info.charAt(i);  

          i++;

      }

      i++;

      while(info.charAt(i)!=' '){

          type=type+info.charAt(i);

          i++;

      }

      i++;

      while(i<len){

          count=count*10+Integer.parseInt(String.valueOf(info.charAt(i)));

          i++;

      }

      if(size.equals("Letter"))

          cost=cost+0.05;

      else if(size.equals("Legal"))

          cost=cost+0.06;

      else if(size.equals("A4"))

          cost=cost+0.055;

      else if(size.equals("A5"))

          cost=cost+0.04;

      if(type.equals("Grayscale"))

          cost=cost+0.01;

      else if(type.equals("Colored"))

          cost=cost+0.10;

      cost=cost*count;

      System.out.printf("print job Cost:$ %.2f\n",cost);

  }

}

cheers i hope this helped !!!

write pseudocode to represent the logic of a program that allows the user to enter a value for one edge of a cube. The program calculates the surface area of one side of the cube, the surface area of the cube, and its volume. The program outputs all the results.

Answers

Answer:

prompt("Enter a value for one edge of a cube")

Store user's value into edgeCube

area = 6 * (edgeCube * edgeCube)

volume = edgeCube * edgeCube * edgeCube

print("One side of the cube is: " + edgecube);

print("The area is: " + area)

print("The volume is: " + volume)

Ask the user to enter a number for red, green, and blue components of an RGB value. Test to make sure each value is between 0 and 255 inclusive. If a color's value is out of range, print which component is not correct (e.g., "Red number is not correct" if the red value is 300). Multiple colors may be out of range.

Answers

Answer:

r = int(input("Enter a number for red channel: ")) g = int(input("Enter a number for green channel: ")) b = int(input("Enter a number for blue channel: "))   if(r < 0 or r >255):    print("Red number is not correct.") if(g < 0 or g >255):    print("Green number is not correct.") if(b < 0 or b >255):    print("Blue number is not correct.")

Explanation:

The solution code is written in Python.

Firstly, prompt user to input three numbers for red, green and blue (Line 1-3).

Next, create three similar if statements to check if the red, green and blue are within the range 0-255 by using logical operator "or" to check if the number is smaller than 0 or bigger than 255. If either one condition is met, display a message to indicate a particular color number is not correct (Line 5-12).

The program written in python 3 which displays the whether the range of RGB values inputted by the user is in range goes thus :

r = int(input('Enter red value between 0 - 255'))

g = int(input('Enter green value between 0 - 255'))

b = int(input('Enter blue value between 0 - 255'))

#accepts inputs for red, green and blue values from the user

vals = {'red':r, 'green':g, 'blue':b}

#read the values into a dictionary and assign the values inputted by the user as the values

for k, v in vals.items():

#iterate through the dictionary as key-value pairs

if(v < 0) or (v > 255):

#Check of the values inputted is within range (0 - 255)

print('%s is not correct' %k)

#for any value which is out of range, display the name of the color and state that it is incorrect.

A sample run of the program ls attached below.

Learn more :https://brainly.com/question/18802298

Write a program to simulate a payroll application. To that affect you will also create an Employee class, according to the specifications below. Since an Employee list might be large, and individual Employee objects may contain significant information themselves, we will store the Employee list as a linked list. You will also be asked to implement a basic linked list from scratch.

Attributes:

• Employee ID: you can use a string – the ID will contain digits and/or hyphens. The ID cannot be changed once an employee object is created.
• Number of hours worked in a week: a floating-point number.
• Hourly pay rate: a floating-point number that represents how much the employee is paid for one hour of work.
• Gross wages: a floating-point number that stores the number of hours times the hourly rate.

Methods:

• A constructor (__init__)
• Setter methods as needed.
• Getter methods as needed.
• This class should overload the __str__ or __repr__ methods so that Employee objects can be displayed using the print() function.

Answers

Eu Ñ sei amigo tenho medo de errar a pergunta

Separating calculations into methods simplifies modifying and expanding programs.
The following program calculates the tax rate and tax to pay, using methods. One method returns a tax rate based on an annual salary.
Run the program below with annual salaries of 40000, 60000, and 0.
Change the program to use a method to input the annual salary.
Run the program again with the same annual salaries as above. Are results the same?
This is the code including what I am working on added. I will not run. I need to remove some areas to designate the scanner as the source of input but I am unsure of which area.
import java.util.Scanner;
public class IncomeTax {
// Method to get a value from one table based on a range in the other table
public static double getCorrespondingTableValue(int search, int [] baseTable, double [] valueTable) {
int baseTableLength = baseTable.length;
double value = 0.0;
int i = 0;
boolean keepLooking = true;
i = 0;
while ((i < baseTableLength) && keepLooking) {
if (search <= baseTable[i]) {
value = valueTable[i];
keepLooking = false;
}
else {
++i;
}
}
return value;
}
public static void readInput(int salaryOne, int salaryTwo, int salaryThree);
annualSalary = 0;
Scanner scnr = new Scanner(System.in);
scnr nextInt();
new annualSalary;
public static void main (String [] args) {
Scanner scnr = new Scanner(System.in);
int annualSalary = 0;
double taxRate = 0.0;
int taxToPay = 0;
int i = 0;
int [] salaryBase = { 20000, 50000, 100000, 999999999 };
double [] taxBase = { .10, .20, .30, .40 };
// FIXME: Change the input to come from a method
System.out.println("\nEnter annual salary (0 to exit): ");
annualSalary = scnr.nextInt();
while (annualSalary > 0) {
taxRate = getCorrespondingTableValue(annualSalary, salaryBase, taxBase);
taxToPay= (int)(annualSalary * taxRate); // Truncate tax to an integer amount
System.out.println("Annual salary: " + annualSalary +
"\tTax rate: " + taxRate +
"\tTax to pay: " + taxToPay);
// Get the next annual salary
// FIXME: Change the input to come from a method
System.out.println("\nEnter annual salary (0 to exit): ");
annualSalary = scnr.nextInt();
}
return;
}
}

Answers

Answer: Provided in the explanation section

Explanation:

Programs:

IncomeTax.java

import java.util.Scanner;

public class IncomeTax {

  // Method to get a value from one table based on a range in the other table

  public static double getCorrespondingTableValue(int search, int [] baseTable, double [] valueTable) {

  int baseTableLength = baseTable.length;

  double value = 0.0;

  int i = 0;

  boolean keepLooking = true;

  i = 0;

  while ((i < baseTableLength) && keepLooking) {

  if (search <= baseTable[i]) {

  value = valueTable[i];

  keepLooking = false;

  }

  else {

  ++i;

  }

  }

  return value;

  }

  public static int readInput(Scanner scan){

      System.out.println("\nEnter annual salary (0 to exit): ");

      int annualSalary = scan.nextInt();

      return annualSalary;

  }

  public static void main (String [] args) {

  Scanner scnr = new Scanner(System.in);

  int annualSalary = 0;

  double taxRate = 0.0;

  int taxToPay = 0;

  int [] salaryBase = { 20000, 50000, 100000, 999999999 };

  double [] taxBase = { .10, .20, .30, .40 };

 

  // FIXME: Change the input to come from a method

  annualSalary = readInput(scnr);

  while (annualSalary > 0) {

  taxRate = getCorrespondingTableValue(annualSalary, salaryBase, taxBase);

  taxToPay= (int)(annualSalary * taxRate); // Truncate tax to an integer amount

  System.out.println("Annual salary: " + annualSalary +

  "\tTax rate: " + taxRate +

  "\tTax to pay: " + taxToPay);

  // Get the next annual salary

  // FIXME: Change the input to come from a method

  annualSalary = readInput(scnr);

  }

  return;

  }

  }

     

Output:

Enter annual salary (0 to exit):

10000

Annual salary: 10000   Tax rate: 0.1   Tax to pay: 1000

Enter annual salary (0 to exit):

50000

Annual salary: 50000   Tax rate: 0.2   Tax to pay: 10000

Enter annual salary (0 to exit):

0

Discuss reason why you may prefer to have cookies disabled on your browser

Answers

Answer:

For me this is because, if I don't accept them they won't let me see what I came there for and my megabyte will be wasting.

Explanation:

Other Questions
Here are some milestones of methods in geography that depend ontechnology. Put them in the order in which they appeared in history.* Using the Earth's magnetic field to determine direction*1 Tying maps to databases1. Navigating by sight, using maps and the shape of the coastlineUsing handheld instruments to measure the position of the sun andstars 2H2 + O2 + 2H20If you have 50 grams of hydrogen (H2), how many moles of water (H20) could beproduced? Can anyone help me with this question please How many individuals show the trait being followed?Correct answer gets brainlest Identify and describe the three ways that mutation affect organisms Which of the following represents the graph of f(x) = 3x 2? graph of exponential rising up to the right, through the point 0, 3 graph of exponential rising up to the right, through the point 0, negative 1 graph of exponential rising up to the right, through the point 0, 1 graph of exponential rising up to the right, through the point 0, negative 2 A circle has a radius of 6 cm. Which calculation would be the correct calculation to work out the circumference? PQRS is a parallelogram. If mQRS = (9x - 20) andmSPQ = (4x + 90), what is the value of x? 22 8.5 14 10 And I also need help with this- Complete the analogy below.Braces are to teeth as____are to eyesA. contact lensesb. make-upC. nosesd. toothbrush What is the surface area of a right cylinder which has a base with radius 9 units and has a height of 12 units? Which of the following statements is true? The first mathematical theory of tides was introduced by Aristotle. Edward Forbes believed life existed on the ocean floor. Benjamin Franklin created the first tide-prediction machine. All of the above. None of the above. You're carrying a 4.0-m-long, 21 kg pole to a construction site when you decide to stop for a rest. You place one end of the pole on a fence post and hold the other end of the pole 35 cm from its tip. How much force must you exert to keep the pole motionless in a horizontal position? Rob is saving to buy a new MP3 player. For every $12 he earns babysitting, he saves $7. On Saturday, Rob earned $72 babysitting. How much money did he save? 1. Plant hormones include the followingexcept.A. insulinB. auxinC. cytokininD. gibberellin Please select the word from the list that best fits the definition Chinese scholar who wrote Historical Records Katelynn measures the height of her bean plant on Monday and again onFriday. She says that her bean plant grew 10 quarter inches. Her partnerrecords 2 1/2 inches on their growth chart for the week. Is her partnerright? Why or why not? *Use words and numbers to explain. * "Organisational behaviour is a field of study that investigates the impact that individuals, groups and structure have on behaviour within the organisations for the purpose of applying such knowledge toward improving an organizations effectiveness."a. Trueb. False Select the correct answer.A school bus has 25 seats, with 5 rows of 5 seats. 15 students from the first grade and 5 students from the second grade travel in the bus. Howmany ways can the students be seated if all the first-grade students occupy the first 3 rows?OA 25P20OB 5P5X20P15,OC15C15 X 10c5OD 15P15x 10P5OE 15P15 x10c5 (-16) - (+12) + (-)