package reservation;
import java.util.*; //For Scanner Class
import java.time.*; //For LocalDate
import java.time.format.*; //For DateTimeFormatter
public class Reservation
{
double perNight = 105.00, finalAmt;
long noDays;
int m, d, y;
LocalDate std, end;
//Sets the Arrival date inputed by the user
void setArrivalDate(LocalDate arrivalDate)
{
std = arrivalDate;
}
//Sets the Departure date inputed by the user
void setDepartureDate(LocalDate departureDate)
{
end = departureDate;
}
//Returns the Arrival date
LocalDate getArrivalDate()
{
return std;
}
//Returns the Departure date
LocalDate getDepartureDate()
{
return end;
}
//Formats the Arrival date as per the requirement given question
String getArrivalDateFormatted()
{
String stdFormat;
stdFormat = \"Arrival Date: \" + std.getMonth() + \" \" + String.valueOf(std.getDayOfMonth())
+ \", \" + String.valueOf(std.getYear());
return stdFormat;
}
//Formats the Departure date as per the requirement given question
String getDepartureDateFormatted()
{
String stdFormat;
stdFormat = \"Departure Date: \" + end.getMonth() + \" \" +
String.valueOf(end.getDayOfMonth()) + \", \" + String.valueOf(end.getYear());
return stdFormat;
}
//Returns the Price per night as per the format
String getPricePerNightFormatted()
{
String pr = \"Price: $\" + String.valueOf(perNight) + \" per night\";
return pr;
}
//Returns the number of nights
long getNumberOfNights()
{
//toEpochDay() returns number of days
noDays = end.toEpochDay() - std.toEpochDay();
return noDays;
}
//Calculates final Amount to be paid
double getTotalPrice()
{
finalAmt = (double)getNumberOfNights() * perNight;
return finalAmt;
}
//Returns the Total amount to be paid as per the format given in the question
String getTotalPriceFormatted()
{
String finA = \"Total price: $\" + String.valueOf(getTotalPrice()) + \" for \" +
String.valueOf(getNumberOfNights()) + \" night\" ;
return finA;
}
//Accepts the Arrival date and Departure date from console
void accept()
{
//Creates object of LocaleDate
LocalDate std1, end1;
//Creates the Date Time Formater object and applies Format Style
//SHORT in mm/dd/yy format
DateTimeFormatter fmt = DateTimeFormatter.ofLocalizedDate(FormatStyle.SHORT);
//Creates Scanner class object to accept data from console
Scanner s = new Scanner(System.in);
System.out.println(\"Enter starting date mm/dd/yyyy: \");
System.out.println(\"Enter the arrival month (1-12):\");
m = s.nextInt(); //Accept data in integer format
System.out.println(\"Enter the arrival day (1-31):\") ;
d = s.nextInt();
System.out.println(\"Enter the arrival year:\") ;
y = s.nextInt();
//Initializes the LocalDate object for Arrival date
std1 = LocalDate.of(y, m, d);
//Sets the SHORT date format
fmt.format(std1);
//Assigns Arrival date to class data member
setArrivalDate(std1);
System.out.println(\"Enter ending date mm/dd/yyyy: \");
System.out.println(\"Enter the departure month (1-12):\");
m = s.nextInt(); //Accept data in integer format
System.out.println(\"Enter the departur.
assignmentTwo/Car.javaassignmentTwo/Car.javapackage assignmentTwo;
// incomplete starter code for assignment two programming 1, sem 2 2014
// author: Kathleen Keogh version 1, incomplete. September 2014
publicclassCarextendsVehicle{
// instance variables
privateint numSeats, numDoors;
privateboolean hatch, tintedWindows;
publicCar(){
}
publicCar(int _numSeats,int _numDoors,boolean _hatch,boolean _tintedWindows){
// insert appropriate initialisation code here based on the parameters provided
}
// get and set methods for each car instance variable
publicint getNumSeats(){
return numSeats;
}
publicboolean setNumSeats(int _numSeats){
returntrue;// change this based on validation
}
publicint getNumDoors(){
return1;// change this to return appropriate value
}
publicvoid setNumDoors(){
}
publicboolean getHatch(){
returntrue;// change this to return the appropriate value
}
publicvoid setHatch(boolean _hatch){
}
publicboolean getTintedWindows(){
returntrue;// update this to return the appropriate value
}
publicvoid setTintedWindows(boolean _tintedWindows){
}
// toString method
publicString toString(){
// insert code here to appropriately return a string of data for this car, use superclass methods where appropriate
return("Car. Make "+ getMake());// change this to return more than just the make
}
}
assignmentTwo/Garage.javaassignmentTwo/Garage.javapackage assignmentTwo;
// Author, Version 1. Starter Code: Kathleen Keogh September 2014
// Author, Version 2. :
// Garage class is for a garage that contains a number of vehicles
publicclassGarage{
//instance variables
Vehicle vehicleList[];
int maxVehicles=10;// default maximum number of vehicles is 10
int currsize;
publicGarage(){// constructor with no parameters
vehicleList =newVehicle[maxVehicles];
currsize=0;
}
publicGarage(int _numMaxVehicles){// constructor with one parameter - maximum number of vehicles for garage
maxVehicles = _numMaxVehicles;
vehicleList =newVehicle[maxVehicles];
currsize =0;
}
// TODO: add get and set methods
// TODO: add toString() method
// TODO: add other methods including addVehicle, sortVehicles
}
assignmentTwo/Rectangle.javaassignmentTwo/Rectangle.javapackage assignmentTwo;
publicclassRectangleextendsShapes{
double length, width;// extra instance variables associated with Rectangle particularly
publicRectangle(){// constructor to create an 'empty' triangle
super("","",0,0);
length =0.0;//initialise length and width to zero for new rectangle
width =0.0;
}
publicRectangle(double initLength,double initWidth,String initName,String initColour,double xCoord,double yCoord){
super(initName, initColour, xCoord, yCoord);// use constructor from super class: Shapes
setLength(initLength);// initialise length to provided value
setWidth(initWidth);
}
publicboolean setLength(double _length){// mutator method to set length to new value
if(_length >0.0){// validate length is positi ...
Modify the Time classattached to be able to work with Date.pdfaaseletronics2013
Modify the Time class(attached) to be able to work with Date class. The Time object should
always remain in a consistent state.
Modify the Date class(attached) to include a Time class object as a composition, a tick member
function that increments the time stored in a Date object by one second, and increaseADay
function to increase day, month and year when it is proper. Please use CISP400V10A4.cpp that
tests the tick member function in a loop that prints the time in standard format during iteration of
the loop to illustrate that the tick member function works correctly. Be aware that we are testing
the following cases:
a) Incrementing into the next minute.
b) Incrementing into the next hour.
c) Incrementing into the next day (i.e., 11:59:59 PM to 12:00:00 AM).
d) Incrementing into the next month and next year.
You can adjust only programs (Date.cpp, Date.h, Time.cpp and Time.h) to generate the
required result but not the code in CISP400V10A4.cpp file.
Expecting results:
// Date.cpp
// Date class member-function definitions.
#include <array>
#include <string>
#include <iostream>
#include <stdexcept>
#include "Date.h" // include Date class definition
using namespace std;
// constructor confirms proper value for month; calls
// utility function checkDay to confirm proper value for day
Date::Date(int mn, int dy, int yr, Time time)
: time01(time)
{
if (mn > 0 && mn <= monthsPerYear) // validate the month
month = mn;
else
throw invalid_argument("month must be 1-12");
year = yr; // could validate yr
day = checkDay(dy); // validate the day
// output Date object to show when its constructor is called
cout << "Date object constructor for date ";
print();
cout << endl;
} // end Date constructor
// print Date object in form month/day/year
void Date::print() const
{
cout << month << '/' << day << '/' << year;
cout << "t";
time01.printStandard();
cout << "t";
time01.printUniversal();
cout << "n";
} // end function print
// output Date object to show when its destructor is called
Date::~Date()
{
cout << "Date object destructor for date ";
print();
cout << endl;
} // end ~Date destructor
// utility function to confirm proper day value based on
// month and year; handles leap years, too
unsigned int Date::checkDay(int testDay) const
{
static const array< int, monthsPerYear + 1 > daysPerMonth =
{ 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
// determine whether testDay is valid for specified month
if (testDay > 0 && testDay <= daysPerMonth[month])
{
return testDay;
} // end if
// February 29 check for leap year
if (month == 2 && testDay == 29 && (year % 400 == 0 || (year % 4 == 0 && year
% 100 != 0)))
{
return testDay;
} // end if
cout << "day (" << testDay << ") set to 1." << endl;
return 1;
} // end function checkDay
// adjust data if day is not proper
void Date::increaseADay()
{
day = checkDay(day + 1);
if (day == 1) // if day wasn't accurate, its value is one
{
month = month + 1; // increase month by 1
if (month > 0 && month >= monthsPerYear) // if.
// PersonData.h
#ifndef PersonData_h
#define PersonData_h
#include
#include
#include
using namespace std;
class PersonData {
protected:
//member variables
string lastName; //holds the users last name
string firstName; //holds the users first name
string address; //holds the users address
string city; //holds the users city
string state; //holds the users state
int zip; //holds the users zip code
int phone; //holds the users phone number
public:
//constructors and destructor
PersonData(); //default constructor
PersonData( string ln , string fn , string addr , string c , string s , int z , int p); // overloaded
constructor
~PersonData(){ /*cout << \"The object has been deleted.\" << endl ;*/ } //destructor
//member functions
//returns the users lastName
string getLastName();
//sets the users lastName
void setLastName( string lastN );
//returns the users firstName
string getFirstName();
//sets the users firstName
void setFirstName( string firstN );
//returns the users address
string getAddress();
//sets the users address
void setAddress( string addr );
//returns the users city
string getCity();
//sets the users city
void setCity( string city );
//returns the users state
string getState();
//sets the users state
void setState( string state );
//returns the users zip
int getZip();
//sets the users zip
void setZip( int zip );
//returns the users phone
int getPhone();
//sets the users phone
void setPhone( int phone );
};
#endif /* PersonData_h */
// PersonData.cpp
#include
#include \"PersonData.h\"
using namespace std;
//constructors and destructor
PersonData::PersonData(){
//defining arbitrary values for member variables
string lastName = \"\"; //holds the users last name
string firstName = \"\"; //holds the users first name
string address = \"\"; //holds the users address
string city = \"\"; //holds the users city
string state = \"\"; //holds the users state
int zip = 0; //holds the users zip code
int phone = 0; //holds the users phone number
}//default constructor
PersonData::PersonData( string strln , string name , string stradd , string liveingcity , string
livingstate , int code , int number){
// user defined values for member variables
string lastName = strln; //holds the users last name
string firstName = name; //holds the users first name
string address = stradd; //holds the users address
string city = liveingcity; //holds the users city
string state = livingstate; //holds the users state
int zip = code; //holds the users zip code
int phone = number; //holds the users phone number
}// overloaded constructor
//member functions
//returns the users lastName
string PersonData::getLastName(){
return lastName;
}
//sets the users lastName
void PersonData::setLastName( string lastN ){
lastName = lastN;
}
//returns the users firstName
string PersonData::getFirstName(){
return firstName;
}
//sets the users firstName
void PersonData::setFirstName( string firstN ){
firstName = firstN;
}
//returns the users address
string PersonData::getAddress(){
retur.
Create a class named Student that has the following member variables.pdfarrowvisionoptics
Create a class named Student that has the following member variables: first name (string), last
name(string), student identification number(int), an integer array where the grades of all classes
are stored, grade point average (gpa) (float). Write appropriate constructor, mutator and accessor
functions for the class along with the following A function that inputs all values from the user
(except for gpa) A function that outputs the names and gpa of students
Solution
/* Java Programme for Grades Calculation */
import java.util.Scanner;
public class Student
{
//Private varibles declaration
private String firstName;
private String lastName;
private int sid;
private int[] grades= new int[10];
int[] tempgrades= new int[10];
int noc;
private float gpa=0;
//Constructor method
Scanner in=new Scanner(System.in); //scanner class object for reading input
public static void main(String[] args)
{
Student st=new Student(); //creating object and calling default constructor
st.readInput();
st.calgpa();
}
//Mutator for firstName
public void setfirstName(String firstName)
{
this.firstName = firstName;
}
//Mutator for lastName
public void setlastName(String lastName)
{
this.lastName = lastName;
}
//Mutator for sid
public void setsid(int sid)
{
this.sid = sid;
}
//Mutator for grades
public void setgrades(int[] grades)
{
this.grades = grades;
}
void readInput() //Function to read input data
{
System.out.println(\"Enter First Name\ \"); //Prompt for name
String temp=in.nextLine(); //reading name
setfirstName(temp); //calling mutator for firstName
System.out.println(\"Enter Last Name\ \"); //Prompt for last name
String temp1=in.nextLine(); //read last anme
setlastName(temp1); //calling mutator for lastName
System.out.println(\"Enter Student ID\ \"); //prompt for student id
int temp2=in.nextInt(); //read student id
setsid(temp2); //calling mutator for sid
System.out.println(\"Enter Number of classes ID\ \"); //Prompt for Number of classes
noc=in.nextInt(); //read Number of classes
System.out.println(\"Enter Grades of classes ID\ \"); //Prompt for Grades of classes
for(int i=0;i Gpa : \" + gpa+\"\ \"); //Dispaly output
}
}
Output :
javac Student.java //Compilation of java programme
java Student //running java programme
Sample output :
Enter First Name
Ashok
Enter Last Name
Kumar
Enter Student ID
101
Enter Number of classes ID
4
Enter Grades of classes ID
10
9
8
7
First Name : Ashok Last Name : Kumar Student Id : 101 --> Gpa : 8.5.
assignmentTwo/Car.javaassignmentTwo/Car.javapackage assignmentTwo;
// incomplete starter code for assignment two programming 1, sem 2 2014
// author: Kathleen Keogh version 1, incomplete. September 2014
publicclassCarextendsVehicle{
// instance variables
privateint numSeats, numDoors;
privateboolean hatch, tintedWindows;
publicCar(){
}
publicCar(int _numSeats,int _numDoors,boolean _hatch,boolean _tintedWindows){
// insert appropriate initialisation code here based on the parameters provided
}
// get and set methods for each car instance variable
publicint getNumSeats(){
return numSeats;
}
publicboolean setNumSeats(int _numSeats){
returntrue;// change this based on validation
}
publicint getNumDoors(){
return1;// change this to return appropriate value
}
publicvoid setNumDoors(){
}
publicboolean getHatch(){
returntrue;// change this to return the appropriate value
}
publicvoid setHatch(boolean _hatch){
}
publicboolean getTintedWindows(){
returntrue;// update this to return the appropriate value
}
publicvoid setTintedWindows(boolean _tintedWindows){
}
// toString method
publicString toString(){
// insert code here to appropriately return a string of data for this car, use superclass methods where appropriate
return("Car. Make "+ getMake());// change this to return more than just the make
}
}
assignmentTwo/Garage.javaassignmentTwo/Garage.javapackage assignmentTwo;
// Author, Version 1. Starter Code: Kathleen Keogh September 2014
// Author, Version 2. :
// Garage class is for a garage that contains a number of vehicles
publicclassGarage{
//instance variables
Vehicle vehicleList[];
int maxVehicles=10;// default maximum number of vehicles is 10
int currsize;
publicGarage(){// constructor with no parameters
vehicleList =newVehicle[maxVehicles];
currsize=0;
}
publicGarage(int _numMaxVehicles){// constructor with one parameter - maximum number of vehicles for garage
maxVehicles = _numMaxVehicles;
vehicleList =newVehicle[maxVehicles];
currsize =0;
}
// TODO: add get and set methods
// TODO: add toString() method
// TODO: add other methods including addVehicle, sortVehicles
}
assignmentTwo/Rectangle.javaassignmentTwo/Rectangle.javapackage assignmentTwo;
publicclassRectangleextendsShapes{
double length, width;// extra instance variables associated with Rectangle particularly
publicRectangle(){// constructor to create an 'empty' triangle
super("","",0,0);
length =0.0;//initialise length and width to zero for new rectangle
width =0.0;
}
publicRectangle(double initLength,double initWidth,String initName,String initColour,double xCoord,double yCoord){
super(initName, initColour, xCoord, yCoord);// use constructor from super class: Shapes
setLength(initLength);// initialise length to provided value
setWidth(initWidth);
}
publicboolean setLength(double _length){// mutator method to set length to new value
if(_length >0.0){// validate length is positi ...
Modify the Time classattached to be able to work with Date.pdfaaseletronics2013
Modify the Time class(attached) to be able to work with Date class. The Time object should
always remain in a consistent state.
Modify the Date class(attached) to include a Time class object as a composition, a tick member
function that increments the time stored in a Date object by one second, and increaseADay
function to increase day, month and year when it is proper. Please use CISP400V10A4.cpp that
tests the tick member function in a loop that prints the time in standard format during iteration of
the loop to illustrate that the tick member function works correctly. Be aware that we are testing
the following cases:
a) Incrementing into the next minute.
b) Incrementing into the next hour.
c) Incrementing into the next day (i.e., 11:59:59 PM to 12:00:00 AM).
d) Incrementing into the next month and next year.
You can adjust only programs (Date.cpp, Date.h, Time.cpp and Time.h) to generate the
required result but not the code in CISP400V10A4.cpp file.
Expecting results:
// Date.cpp
// Date class member-function definitions.
#include <array>
#include <string>
#include <iostream>
#include <stdexcept>
#include "Date.h" // include Date class definition
using namespace std;
// constructor confirms proper value for month; calls
// utility function checkDay to confirm proper value for day
Date::Date(int mn, int dy, int yr, Time time)
: time01(time)
{
if (mn > 0 && mn <= monthsPerYear) // validate the month
month = mn;
else
throw invalid_argument("month must be 1-12");
year = yr; // could validate yr
day = checkDay(dy); // validate the day
// output Date object to show when its constructor is called
cout << "Date object constructor for date ";
print();
cout << endl;
} // end Date constructor
// print Date object in form month/day/year
void Date::print() const
{
cout << month << '/' << day << '/' << year;
cout << "t";
time01.printStandard();
cout << "t";
time01.printUniversal();
cout << "n";
} // end function print
// output Date object to show when its destructor is called
Date::~Date()
{
cout << "Date object destructor for date ";
print();
cout << endl;
} // end ~Date destructor
// utility function to confirm proper day value based on
// month and year; handles leap years, too
unsigned int Date::checkDay(int testDay) const
{
static const array< int, monthsPerYear + 1 > daysPerMonth =
{ 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
// determine whether testDay is valid for specified month
if (testDay > 0 && testDay <= daysPerMonth[month])
{
return testDay;
} // end if
// February 29 check for leap year
if (month == 2 && testDay == 29 && (year % 400 == 0 || (year % 4 == 0 && year
% 100 != 0)))
{
return testDay;
} // end if
cout << "day (" << testDay << ") set to 1." << endl;
return 1;
} // end function checkDay
// adjust data if day is not proper
void Date::increaseADay()
{
day = checkDay(day + 1);
if (day == 1) // if day wasn't accurate, its value is one
{
month = month + 1; // increase month by 1
if (month > 0 && month >= monthsPerYear) // if.
// PersonData.h
#ifndef PersonData_h
#define PersonData_h
#include
#include
#include
using namespace std;
class PersonData {
protected:
//member variables
string lastName; //holds the users last name
string firstName; //holds the users first name
string address; //holds the users address
string city; //holds the users city
string state; //holds the users state
int zip; //holds the users zip code
int phone; //holds the users phone number
public:
//constructors and destructor
PersonData(); //default constructor
PersonData( string ln , string fn , string addr , string c , string s , int z , int p); // overloaded
constructor
~PersonData(){ /*cout << \"The object has been deleted.\" << endl ;*/ } //destructor
//member functions
//returns the users lastName
string getLastName();
//sets the users lastName
void setLastName( string lastN );
//returns the users firstName
string getFirstName();
//sets the users firstName
void setFirstName( string firstN );
//returns the users address
string getAddress();
//sets the users address
void setAddress( string addr );
//returns the users city
string getCity();
//sets the users city
void setCity( string city );
//returns the users state
string getState();
//sets the users state
void setState( string state );
//returns the users zip
int getZip();
//sets the users zip
void setZip( int zip );
//returns the users phone
int getPhone();
//sets the users phone
void setPhone( int phone );
};
#endif /* PersonData_h */
// PersonData.cpp
#include
#include \"PersonData.h\"
using namespace std;
//constructors and destructor
PersonData::PersonData(){
//defining arbitrary values for member variables
string lastName = \"\"; //holds the users last name
string firstName = \"\"; //holds the users first name
string address = \"\"; //holds the users address
string city = \"\"; //holds the users city
string state = \"\"; //holds the users state
int zip = 0; //holds the users zip code
int phone = 0; //holds the users phone number
}//default constructor
PersonData::PersonData( string strln , string name , string stradd , string liveingcity , string
livingstate , int code , int number){
// user defined values for member variables
string lastName = strln; //holds the users last name
string firstName = name; //holds the users first name
string address = stradd; //holds the users address
string city = liveingcity; //holds the users city
string state = livingstate; //holds the users state
int zip = code; //holds the users zip code
int phone = number; //holds the users phone number
}// overloaded constructor
//member functions
//returns the users lastName
string PersonData::getLastName(){
return lastName;
}
//sets the users lastName
void PersonData::setLastName( string lastN ){
lastName = lastN;
}
//returns the users firstName
string PersonData::getFirstName(){
return firstName;
}
//sets the users firstName
void PersonData::setFirstName( string firstN ){
firstName = firstN;
}
//returns the users address
string PersonData::getAddress(){
retur.
Create a class named Student that has the following member variables.pdfarrowvisionoptics
Create a class named Student that has the following member variables: first name (string), last
name(string), student identification number(int), an integer array where the grades of all classes
are stored, grade point average (gpa) (float). Write appropriate constructor, mutator and accessor
functions for the class along with the following A function that inputs all values from the user
(except for gpa) A function that outputs the names and gpa of students
Solution
/* Java Programme for Grades Calculation */
import java.util.Scanner;
public class Student
{
//Private varibles declaration
private String firstName;
private String lastName;
private int sid;
private int[] grades= new int[10];
int[] tempgrades= new int[10];
int noc;
private float gpa=0;
//Constructor method
Scanner in=new Scanner(System.in); //scanner class object for reading input
public static void main(String[] args)
{
Student st=new Student(); //creating object and calling default constructor
st.readInput();
st.calgpa();
}
//Mutator for firstName
public void setfirstName(String firstName)
{
this.firstName = firstName;
}
//Mutator for lastName
public void setlastName(String lastName)
{
this.lastName = lastName;
}
//Mutator for sid
public void setsid(int sid)
{
this.sid = sid;
}
//Mutator for grades
public void setgrades(int[] grades)
{
this.grades = grades;
}
void readInput() //Function to read input data
{
System.out.println(\"Enter First Name\ \"); //Prompt for name
String temp=in.nextLine(); //reading name
setfirstName(temp); //calling mutator for firstName
System.out.println(\"Enter Last Name\ \"); //Prompt for last name
String temp1=in.nextLine(); //read last anme
setlastName(temp1); //calling mutator for lastName
System.out.println(\"Enter Student ID\ \"); //prompt for student id
int temp2=in.nextInt(); //read student id
setsid(temp2); //calling mutator for sid
System.out.println(\"Enter Number of classes ID\ \"); //Prompt for Number of classes
noc=in.nextInt(); //read Number of classes
System.out.println(\"Enter Grades of classes ID\ \"); //Prompt for Grades of classes
for(int i=0;i Gpa : \" + gpa+\"\ \"); //Dispaly output
}
}
Output :
javac Student.java //Compilation of java programme
java Student //running java programme
Sample output :
Enter First Name
Ashok
Enter Last Name
Kumar
Enter Student ID
101
Enter Number of classes ID
4
Enter Grades of classes ID
10
9
8
7
First Name : Ashok Last Name : Kumar Student Id : 101 --> Gpa : 8.5.
struct procedure { Date dateOfProcedure; int procedureID.pdfanonaeon
struct procedure
{
Date dateOfProcedure;
int procedureID;
int procedureProviderID;
};
Data.h
#include
#include
class Date
{
friend ostream& operator<<( ostream &, const Date & );
// allows easy output to a ostream
public:
Date( int m = 1, int d = 1, int y = 1900 ); // constructor, note the default values
void setDate( int, int, int ); // set the date const
Date &operator+=( int ); // add days, modify object
bool leapYear( int) const; // is this a leap year?
bool endOfMonth( int ) const; // is this end of month?
int getMonth ( ) const;
int getDay ( ) const;
int getYear ( ) const;
string getMonthString( ) const;
private:
int month;
int day;
int year;
static const int days[]; // array of days per month static const string monthName[]; // array of
month names
void helpIncrement();
// utility function
}; #endif Data.cpp // Member function definitions for Date
class in separate
date.cpp
#include
#include \"date.h\"
#include // Initialize static members at file scope; // one class-wide copy.
const int Date::days[] = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; const string
Date::monthName[] = { \"January\", \"February\", \"March\", \"April\", \"May\", \"June\",
\"July\", \"August\", \"September\", \"October\", \"November\", \"December\" };
// Date constructor
Date::Date(int m, int d, int y)
{
setDate(m, d, y); } // Set the date
void Date::setDate(int mm, int dd, int yy)
{
month = (mm >= 1 && mm <= 12) ? mm : 1; year = (yy >=1900&& yy <= 2100) ? yy
: 1900; // test for a leap year
if (month == 2 && leapYear(year)) day = (dd >= 1 && dd <= 29) ? dd : 1;
else
day =(dd >= 1 && dd <= days[month]) ? dd : 1;
} // Add a specific number of days to a date
const Date &Date::operator+=(int additionalDays)
{
for (int i = 0; i < additionalDays; i++) helpIncrement();
return *this; // enables cascading
} // If the year is leap year, return true; //
otherwise, return false
bool Date::leapYear(int testYear)
const
{
if (testYear % 400 == 0 || (testYear %100 != 0 && testYear % 4 == 0)) return true; // a
leap year
else
return false; // not a leap year
} // Determine if the day is the end of the month
bool Date::endOfMonth(int testDay)
const
{
if (month == 2 && leapYear(year))
return (testDay == 29); // last day of Feb. in leap year
else
return (testDay == days[month]);
} // Function to help increment the date
void Date::helpIncrement()
{
if (!endOfMonth(day))
{
// date is not at the end of the month
day++;
}
else if (month < 12)
{
// date is at the end of the month, but month < 12 day = 1; ++month;
}
else
{
// end of month and year: last day of the year
day = 1;
month = 1;
++year;
} }
// Overloaded output operator
ostream &operator<<(ostream& output, const Date &d)
{
output << d.monthName[d.month] << \' \' << d.day << \", \"<< d.year;
return output; // enables cascading
}
int Date::getMonth() const //
{
Public:
int month[20];
If(month[]!=”/0”)
Cout<<”Enter Month :-<>month;
Elseif (month[]<12)
{
Cout<>month[];
else
return month;
}
int Date::getDay() const //
{
Pu.
Production.javapublic class Production { Declaring instance.pdfsooryasalini
Production.java
public class Production {
//Declaring instance variables
private String title;
private String director;
private String writer;
//Parameterized constructor
public Production(String title, String director, String writer) {
super();
this.title = title;
this.director = director;
this.writer = writer;
}
//Setters and getters.
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getDirector() {
return director;
}
public void setDirector(String director) {
this.director = director;
}
public String getWriter() {
return writer;
}
public void setWriter(String writer) {
this.writer = writer;
}
//display() method which displays the Instance variable values
public void display()
{
System.out.println(\"Title: \" + this.title);
System.out.println(\"Director: \" + this.director);
System.out.println(\"Writer: \" + this.writer);
}
//toString() method is used to display the contents of an object
@Override
public String toString() {
return \"Title :\" + title + \"\ Director :\" + director
+ \"\ Writer :\" + writer;
}
}
___________________________________________
Film.java
public class Film extends Production{
//Declaring instance variables
private int boxOfficeGross;
//Parameterized constructor
public Film(String title, String director, String writer, int boxOfficeGross) {
super(title, director, writer);
this.boxOfficeGross = boxOfficeGross;
}
//Setters and getters.
public int getBoxOfficeGross() {
return boxOfficeGross;
}
public void setBoxOfficeGross(int boxOfficeGross) {
this.boxOfficeGross = boxOfficeGross;
}
//display() method which displays the Instance variable values
public void display()
{
System.out.println(\"BoxOfiiceGross: \" + this.boxOfficeGross);
}
//toString() method is used to display the contents of an object
@Override
public String toString() {
return super.toString()+\"\ BoxOfficeGross :\" + boxOfficeGross+\"\ \";
}
}
_______________________________________________
Play.java
public class Play extends Production {
//Declaring instance variables
private int performances;
//Parameterized constructor
public Play(String title, String director, String writer, int performances) {
super(title, director, writer);
this.performances = performances;
}
//Setters and getters.
public int getPerformances() {
return performances;
}
public void setPerformances(int performances) {
this.performances = performances;
}
//display() method which displays the Instance variable values
public void display()
{
System.out.println(\"Performances: \" + this.performances);
}
//toString() method is used to display the contents of an object
@Override
public String toString() {
return super.toString()+\"\ Performances :\" + performances+\"\ \";
}
}
_______________________________________________
Musical.java
public class BobsTerribleTests
{
public static void main(String[] args)
{
//Creating an Film Object by passing parameters
Film titanic = new Film(\"Titanic\", \"James Cameron\", \"James Cameron\.
operating system linux,ubuntu,Mac Geometri.pdfaquadreammail
//operating system linux,ubuntu,Mac
/*********************GeometricObject.java**********************/
public abstract class GeometricObject {
private String color = \"white\";
private boolean filled;
// default constructure
public GeometricObject() {
super();
// TODO Auto-generated constructor stub
}
// construct a Geometric Object
// parameterized constructure
public GeometricObject(String color, boolean filled) {
this.color = color;
this.filled = filled;
}
/** Getter method for color */
public String getColor() {
return color;
}
/** Setter method for color */
public void setColor(String color) {
this.color = color;
}
/**
* Getter method for filled. Since filled is boolean, so the gret method
* name is isFilled
*/
public boolean isFilled() {
return filled;
}
/** Setter method for filled */
public void setFilled(boolean filled) {
this.filled = filled;
}
/** Abstract method for FindArea */
public abstract double findArea();
/** Abstract method for findPerimeter */
public abstract double findPerimeter();
}
/*****************************Octagon.java**************/
public class Octagon extends GeometricObject implements Cloneable, Comparable {
private double side;
/** construct a Octagon with specified side */
public Octagon(double side) {
super();
this.side = side;
}
/** Implement the abstract method findArea in GeometricObject */
@Override
public double findArea() {
double area = (2 + 4 / Math.sqrt(2)) * side * side;
return area;
}
/** Implement the abstract method findArea in findPerimeter */
@Override
public double findPerimeter() {
double perimeter = 8 * side;
return perimeter;
}
/** Implement the compareTo method in Comparable interface */
@Override
public int compareTo(Object o) {
// TODO Auto-generated method stub
return 0;
}
public Object clone() throws CloneNotSupportedException {
return super.clone();
}
}
/*******************App.java*******************/
public class App {
public static void main(String[] args) {
Octagon a1 = new Octagon(5);//creating object of octagon
System.out.println(\"Area of a1 is \" + a1.findArea());
System.out.println(\"Perimeter of a1 is \" + a1.findPerimeter());
Object a2;
try {
a2 = a1.clone();
String result = (a1.compareTo(a2) == 0) ? \"a1 and its clone a2 have the same area\"
: \"a1 and its clone a2 have different areas\";
System.out.println(\"Compare a1 and its clone a2:\ \\t \" + result);
System.out.println(\"Hashcode of a1: \" + a1.hashCode());
System.out.println(\"Hashcode of a2: \" + a2.hashCode());
System.out.println(\"Displaying a1: \" + a1);
System.out.println(\"Displaying a2: \" + a2);
} catch (CloneNotSupportedException e) {
e.printStackTrace();
}
}
}
/*****************output***************/
gopal@gopal:~/Desktop/chegg$ javac GeometricObject.java
gopal@gopal:~/Desktop/chegg$ javac Octagon.java
gopal@gopal:~/Desktop/chegg$ javac App.java
gopal@gopal:~/Desktop/chegg$ java App
Area of a1 is 120.71067811865476
Perimeter of a1 is 40.0
Compare a1 and its clone a2:
a1 and its clone a2 have the same area
.
So Far I have these two classes but I need help with my persontest c.pdfarihantgiftgallery
So Far I have these two classes but I need help with my persontest class:
The next step is to add method calls for the accessor methods after each input:
//Reading and updating values
System.out.print(\"\ Enter Person Name: \");
person1.setPersonName(sc.nextLine());
System.out.println(\"You entered: \" + person1.getPersonName());
Call the accessor function each time you ask for input, after capturing that input. Then repeat for
a second Person, only this time call the constructor that takes the student id as a parameter.
7 import java.util.Scanner;
8
9 class PersonTest
10 {
11 //Main method
12 public static void main(String args[])
13 {
14 Scanner sc = new Scanner(System.in);
15
16 //Creating object
17 Persons_Information person1 = new Persons_Information();
18
19 //Reading and updating values
20 System.out.print(\"\ Enter Person Name: \");
21 person1.setPersonName(sc.nextLine());
22
23 System.out.print(\"\ Enter Current Address: \");
24 person1.setCurrentAdress(sc.nextLine());
25
26 System.out.print(\"\ Enter Permanent Address: \");
27 person1.setpermanentAdress(sc.nextLine());
28
29 System.out.print(\"\ Enter ID number: \");
30 person1.setIdNumber(sc.nextInt());
31
32 sc.nextLine();
33
34 System.out.print(\"\ Enter Birth Date: \");
35 person1.setBirthDate(sc.nextLine());
36
37
38 System.out.print(\"\ Enter Person Age: \");
39 person1.setPersonAge(sc.nextInt());
40
41
42 System.out.print(\"\ Enter Entry Year: \");
43 person1.setEntryYear(sc.nextInt());
44
45
46 System.out.print(\"\ Enter Total Years: \");
47 person1.setTotalYears(sc.nextInt());
48
49 //Printing person 1 details
50 System.out.println(\"\ Person 1: \ \" + person1.toString());
51 }
52 }
Solution
Persons_Information.java
public class Persons_Information {
//Declaring instance variables
private String personName;
private String currentAdress;
private String permanentAdress;
private int idNumber;
private String birthDate;
private int personAge;
private int entryYear;
private int totalYears;
//Zero argumented constructor
public Persons_Information()
{
}
//Parameterized constructor
public Persons_Information(int idNumber) {
this.idNumber = idNumber;
}
//Getters and setters
public String getPersonName() {
return personName;
}
public void setPersonName(String personName) {
this.personName = personName;
}
public String getCurrentAdress() {
return currentAdress;
}
public void setCurrentAdress(String currentAdress) {
this.currentAdress = currentAdress;
}
public String getPermanentAdress() {
return permanentAdress;
}
public void setPermanentAdress(String permanentAdress) {
this.permanentAdress = permanentAdress;
}
public int getIdNumber() {
return idNumber;
}
public void setIdNumber(int idNumber) {
this.idNumber = idNumber;
}
public String getBirthDate() {
return birthDate;
}
public void setBirthDate(String birthDate) {
this.birthDate = birthDate;
}
public int getPersonAge() {
return personAge;
}
public void setPersonAge(int personAge) {
this.personAge = personAge;
}
public int getEntryYe.
Tank Battle - A simple game powered by JMonkey engineFarzad Nozarian
A simple two player java-based game powered by JMonkey game engine which implements many standard object oriented design patterns such as Singleton, Composite, Strategy and etc.
I Have the following Java program in which converts Date to Words an.pdfallystraders
I Have the following Java program in which converts Date to Words and the only thing I have to
do now is add a boolean for a leap year. ( I am using Apache NetBeans) please explain where the
boolean goes.
Like this:
I need the code working with the boolean added, Thank you!!!
package a1_demo;
import java.util.Scanner;
public class MainApp {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.print("Welcome to the Date to Words Converter!\n\n");
while ( true ) {
// get user input
String str_MM_DD_YYYY = Validator.getString(
Validator.sc,
"Enter date in MM/DD/YYYY format: "
);
// convert text to ints:
// "11/22/3333" - > int, int int
String[] dateComponents = str_MM_DD_YYYY.split( "/" );
if ( dateComponents.length != 3 ) {
System.out.println("\t\t Bad input, please retry...");
continue;
}
int month = 0;
int day = 0;
int year = 0;
try {
month = Integer.parseInt(dateComponents[ 0 ]);
day = Integer.parseInt(dateComponents[ 1 ]);
year = Integer.parseInt(dateComponents[ 2 ]);
} catch ( java.lang.NumberFormatException ex ) {
System.out.println("\t\t numeric values are expected, please retry...");
continue;
}
Date2TextConverter converter = new Date2TextConverter( month, day, year );
System.out.print( converter.month2text() );
System.out.print( " " );
System.out.print( converter.day2text() );
System.out.print( " " );
System.out.print( converter.year2text() );
System.out.println();
}// endless while loop
}//main
}//class MainApp
package a1_demo;
public class Date2TextConverter {
//---------------------------------------
// data
//---------------------------------------
int month = 0;
int day = 0;
int year = 0;
//---------------------------------------
// constructors
//---------------------------------------
public Date2TextConverter(int month, int day, int year )
{
this.month = month;
this.day = day;
this.year = year;
}//Date2TextConverter
//---------------------------------------
// operations
//---------------------------------------
public String month2text()
{
switch( month )
{
case 1: return "Jan";
case 2: return "Feb";
case 3: return "Mar";
case 4: return"April";
case 5: return"May";
case 6: return"June";
case 7: return"July";
case 8: return"Aug";
case 9: return"Sep";
case 10: return"Oct";
case 11: return"Nov";
case 12: return"Dec";
//...
default:
return "Invalid Month";
}
}//month2text
public String day2text()
{
//return Integer.toString( day );
return number2words (day);
}//day2text
public String year2text()
{
int century = year / 100;
int yearInCentury = year % 100;
String centuryText = number2words( century );
String yearText = number2words( yearInCentury );
if ( yearInCentury < 10 ) {
return centuryText + " zero " + yearText;
} else {
return centuryText + " " + yearText;
}
}//year2text
private String number2words( int number ) {
// convert to text a number 0 through 99
if ( number < 20 ) {
// 0, 1, 2, 3, ..., 19
return zero2nineteen[ number ];
} else if ( number % 10 == 0 ) {
// 20, 30, 40, ... 90
return .
URGENTJavaPlease updated the already existing Java program and m.pdferremmfab
URGENT
Java
Please updated the already existing Java program and modify it with the steps below:
Where it says (\"text file path gets input into here\"); in the program link the path instead of that
with a text file with this data in it:
Copy and paste this and use as text file and input the path for the text file where it says \"text file
path gets input into here\".
2000/Alex/0110/0120/0
2001/Bill/0210/0220/0
2002/Chris/0310/0320/0
2003/Devon/0140/0420/0
2004/Eli/0510/0520/1
2005/Fred/0610/0620/2
2006/Gilbert/0710/0820/3
2007/Herbert/0910/0920/4
2008/Kim/1010/1020/5
###################################################################
import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;
//setting variables to string or int
public class Storm {
private int stormYear;
private int stormMag;
private String stormStart;
private String stormEnd;
private String stormName;
/**
* Constructor
* Storing all variables from text file
* @param stormName
* @param stormYear
* @param stormStart
* @param stormEnd
* @param stormMag
*/
public Storm(String stormName, int stormYear, String stormStart, String stormEnd, int
stormMag) {
this.stormName = stormName;
this.stormYear = stormYear;
this.stormStart = stormStart;
this.stormEnd = stormEnd;
this.stormMag = stormMag;
}
/**************************************************************/
/*Method: Get and Set */
/*Purpose: They serve to set&get values from class variables */
/*Parameters: */
/*String target: Storm Name */
/*Return: Storm Name */
/**************************************************************/
public String getStormName() {
return stormName;
}
/**
* @param stormName the stormName to set
*/
public void setStormName(String stormName) {
this.stormName = stormName;
}
/**
* @return the stormYear
*/
public int getStormYear() {
return stormYear;
}
/**
* @param stormYear the stormYear to set
*/
public void setStormYear(int stormYear) {
this.stormYear = stormYear;
}
/**
* @return the stormStart
*/
public String getStormStart() {
return stormStart;
}
/**
* @param stormStart the stormStart to set
*/
public void setStormStart(String stormStart) {
this.stormStart = stormStart;
}
//return the stormEnd
public String getStormEnd() {
return stormEnd;
}
//param stormEnd the stormEnd to set
public void setStormEnd(String stormEnd) {
this.stormEnd = stormEnd;
}
//return the stormMag
public int getStormMag() {
return stormMag;
}
/**
* @param stormMag the stormMag to set
*/
public void setStormMag(int stormMag) {
this.stormMag = stormMag;
}
/**************************************************************/
/*Method:String toString */
/*Purpose: convert to a string */
/*Parameters: */
/*String target: Storm Name */
/*Return: Storm Name */
/**************************************************************/
public String toString() {
String s = \"\ \" + getStormYear() + \"/ \" + getStormName() + \" \" ;
if(getStormMag() == -1){
s= s + \"(no info)\";
}
else {
if((getStormMag() == 0)){
s = s + \"(tropi.
I am having a hard time with this problem, can you help me #5. .pdfaroramobiles1
I am having a hard time with this problem, can you help me ???
#5. fill in the copy contructor so that it sets its data to a copy of the data of the Coin that is passed
in. Be sure that it creates a DEEP COPY. ( assuming that the Country class has a copy
constructor that creates one).
public class Coin {
//data
protected Country country;
protected String coinName;
protected int value;
// constructor
// default constructor
public Coin()
{
this.country=new Country(\"US\");
this.coinName=\"Quater\";
this.value=25;
}
//parametirezed constructor
public Coin(Country where,String theName,int theValue)
{
this.country=where;
this.coinName=theName;
this.value=theValue;
}
//copy constructor
public Coin(Coin another)
{
}
//methods
//getValue()-returns its value
public int getValue()
{
return value;
}
//toString-returns its String representation
public String tostring()
{
return coinName+\"with value\"+value;
}
}
Solution
// Copy constructor modified
public Coin(Coin another)
{
this.country=new Country(another.country); // call to the copy Constructor of Country class
this.coinName=another.coinName; // assigns instance member coinName of another object to
coinName of //current object
this.value=another.value; // assigns instance member value of another object to value of current
object
}.
Modify the Date class that was covered in the lecture which overload.pdfsaxenaavnish1
Modify the Date class that was covered in the lecture which overloaded the increment and stream
insertion operators.
The new version of the class should have the following overloaded operators:
(=) subtraction assignment operator :: subtracts the right operand from the left operand and
assigns the result to the left operand.
This operator should cause appropriate number of decrements to the object's 'day' member. It
also checks appropriate decrements to the 'month' and 'year' data members, if necessary.
(>>) cin 's stream extraction operator :: This operator should prompt the user for a date to be
stored in a Date object (you can specify your own format and prompt the user for the same).
Write a driver program and test the operators with the Date objects.
The program should have the following additional requirements:
The operator overloaded functions should be non-member functions.
Input validation (day, month) for the Date object.
The subtraction assignment operator (=) should work with end of month, end of year, and leap
year conditions as shown in the example output below.
Minimum three files (main.cpp, Date.h, Date.cpp). Submit your code as:
LastName_FirstName_Q2.zip (containing all files).
Example output:
Enter a date in format mm-dd-yyyy
01-01-2023
Date d1 is: January 1, 2023 // Check a valid date
Date (d1 -= 3) is: December 29, 2022 // Decrement by 3 days
Date d2 is: March 2, 2008
Date (d2-=2) is: February 29, 2008 // leap year has 29 days
Date.h
// Fig. 10.6: Date.h
// Date class definition with overloaded increment operators.
#ifndef DATE_H
#define DATE_H
#include
#include
class Date {
friend std::ostream& operator<<(std::ostream&, const Date&);
public:
Date(int m = 1, int d = 1, int y = 1900); // default constructor
void setDate(int, int, int); // set month, day, year
Date& operator++(); // prefix increment operator
Date operator++(int); // postfix increment operator
Date& operator+=(unsigned int); // add days, modify object
static bool leapYear(int); // is year a leap year?
bool endOfMonth(int) const; // is day at the end of month?
private:
unsigned int month;
unsigned int day;
unsigned int year;
static const std::array days; // days per month
void helpIncrement(); // utility function for incrementing date
};
#endif
Date.cpp
#include
#include
#include "Date.h"
using namespace std;
// initialize static member; one classwide copy
const array Date::days{
0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
// Date constructor
Date::Date(int month, int day, int year) {
setDate(month, day, year);
}
// set month, day and year
void Date::setDate(int mm, int dd, int yy) {
if (mm >= 1 && mm <= 12) {
month = mm;
}
else {
throw invalid_argument{"Month must be 1-12"};
}
if (yy >= 1900 && yy <= 2100) {
year = yy;
}
else {
throw invalid_argument{"Year must be >= 1900 and <= 2100"};
}
// test for a leap year
if ((month == 2 && leapYear(year) && dd >= 1 && dd <= 29) ||
(dd >= 1 && dd <= days[month])) {
day = dd;
}
else {
throw invalid_argument{
"Da.
I have the following code and I need to know why I am receiving the .pdfezzi552
Edwards Manufacturing Company purchases two component parts from three different suppliers.
The suppliers have limited capacity, and no one supplier can meet all the company’s needs. In
addition, the suppliers charge different prices for the components. Component price data (in
price per unit) are as follows:
Each supplier has a limited capacity in terms of the total number of components it can supply.
However, as long as Edwards provides sufficient advance orders, each supplier can devote its
capacity to component 1, component 2, or any combination of the two components, if the total
number of units ordered is within its capacity. Supplier capacities are as follows:
If the Edwards production plan for the next period includes 1000 units of component 1 and 800
units of component 2, what purchases do you recommend? That is, how many units of each
component should be ordered from each supplier? Round your answers to the nearest whole
number.
What is the total purchase cost for the components? Round your answer to the nearest dollar.
$ ????SupplierComponent1231$11$10$132$10$11$11
Solution
For component 1:
supplier 2 have minimum cost and capacity 1050.
So all the component 1 (1000) can be purchased from supplier 2.
So, supplier 2 have 50 more capacity.
Now, supplier 1 have minimum cost for component 2 and have capacity of 650.
so, number of component 2 from supplier1 can be 650.
Now, we need 150 more component 2.
supplier 2 and 3 have same cost for component 2.
supllier have only 50 capacity now and supplier have 850.
So, 150 component 2 can be purchased from supplier 3.
Let y be the number of components fromSupplier123TotalcostComponent
1010000100010000Component 265001508008150Total cost18150.
import java.util.;import acm.program.;public class FlightPla.pdfanushasarees
import java.util.*;
import acm.program.*;
public class FlightPlanner extends ConsoleProgram {
/* Private instance variables */
private FlightDB flights; //creates a new database
private ArrayList enteredCities = new ArrayList(); //keeps track of entered cities
private String firstCity; //keeps track of the first city entered by the user
public void init() {
//passes the text file to the database to read and parse
flights = new FlightDB(\"flights.txt\");
}
public void run() {
welcome();
askForFistCity();
askForMoreCities();
printFinalRoute();
}
/* Welcomes the user */
private void welcome() {
println(\"Welcome to Flight Planner\");
println(\"Here is a list of all the cities in our database\");
Iterator it = flights.getCities();
while(it.hasNext()) {
println(\" \" + it.next());
}
println(\"Let\'s plan a round-trip route!\");
}
/* asks the user for the starting city and prints out
* all the possible destination cities for that city */
private void askForFistCity() {
while(true) {
firstCity = readLine(\"Enter the starting city: \");
if(flights.ContainsKey(firstCity)) {
enteredCities.add(firstCity);
break;
}
else{
println(\"You can\'t get to that city by a direct flight.\");
println(\"Here is a list of all the cities in our database\");
Iterator it = flights.getCities();
while(it.hasNext()) {
println(\" \" + it.next());
}
}
}
println(\"From \" + firstCity + \" you can fly directly to:\");
Iterator it = flights.findRoute(firstCity);
while(it.hasNext()) {
println(\" \" + it.next());
}
}
/* asks the user for the cities he/she wants to fly to,
* and prints out possible destination cities for each city
* until the user enters the starting city */
private void askForMoreCities() {
String city = firstCity;
String lastCity = city;
while(true) {
city = readLine(\"Where do you want to go from \" + city + \"? \");
if(city.equals(firstCity)) {
break;
}
if(flights.ContainsKey(city) == true) {
lastCity = city;
enteredCities.add(city);
}
else{
city = lastCity;
println(\"You can\'t get to that city by a direct flight.\");
}
println(\"From \" + city + \" you can fly directly to:\");
Iterator it = flights.findRoute(city);
while(it.hasNext()) {
println(\" \" + it.next());
}
}
}
/* prints out the chosen route */
private void printFinalRoute() {
println(\"The route you\'ve chosen is\");
String route = enteredCities.get(0);
for(int i = 1; i \" + enteredCities.get(i);
}
route += \" -> \" + enteredCities.get(0);
println(route);
}
}
import acm.program.*;
public class FlightPlanner extends ConsoleProgram {
/* Private instance variables */
private FlightDB flights; //creates a new database
private ArrayList enteredCities = new ArrayList(); //keeps track of entered cities
private String firstCity; //keeps track of the first city entered by the user
public void init() {
//passes the text file to the database to read and parse
flights = new FlightDB(\"flights.txt\");
}
public void run() {
welcome();
askForFistCity();
askForMoreCities();
printFinalRoute();
}
/* Welcomes the use.
proj6/Collision.javaproj6/Collision.javapackage proj6;
import java.util.ArrayList;
/**
* Collision objects represent individual collisions occuring on NYC streets.
* Each object contains information regarding the time, location, number
* of injuries and fatalities and types of involved vehicles.
* @author Joanna K.
*
*/
publicclassCollisionimplementsComparable<Collision>{
staticprivateSortOrder sortOrder =SortOrder.ZIP;
privateString date;
privateString time;
privateString borough;
privateString zip;
privateint personsInjured;
privateint personsKilled;
privateint pedestriansInjured;
privateint pedestriansKilled;
privateint cyclistsInjured;
privateint cyclistsKilled;
privateint motoristsInjured;
privateint motoristsKilled;
privateString vehicleCode1;
privateString vehicleCode2;
privateString uniqueKey;
/**
* Creates a Collision object given an array of entries.
* There should be 21 string entries in the following order:
* date
* time
* borough
* zip
* lattitude^
* longitude ^
* on street name^
* cross street name ^
* personsInjured
* personsKilled
* pedestriansInjured
* pedestriansKilled
* cyclistsInjured
* cyclistsKilled
* motoristsInjured
* motoristsKilled
* contributing factor vehicle 1^
* contributing factor vehicle 2^
* uniqueKey
* vehicleCode1
* vehicleCode2
* The entries indicated with ^ are not used.
*
* @param entries an array of entries containing information about the
* collision
* @throws IllegalArgumentException when the Collision object cannot be created
* due to errors or incompleteness of the entries parameter
*/
publicCollision(ArrayList<String> entries )throwsIllegalArgumentException{
date = entries.get(0);
time = entries.get(1);
borough = entries.get(2);
zip = entries.get(3);
if(!verifyZip(zip)){
thrownewIllegalArgumentException("invalid zip");
}
try{
personsInjured =Integer.parseInt(entries.get(8));
personsKilled =Integer.parseInt(entries.get(9));
pedestriansInjured =Integer.parseInt(entries.get(10));
pedestriansKilled =Integer.parseInt(entries.get(11));
cyclistsInjured =Integer.parseInt(entries.get(12));
cyclistsKilled =Integer.parseInt(entries.get(13));
motoristsInjured =Integer.parseInt(entries.get(14));
motoristsKilled =Integer.parseInt(entries.get(15));
}
catch(NumberFormatException ex ){
thrownewIllegalArgumentException( ex.getMessage());
}
uniqueKey = entries.get(18);
vehicleCode1 = entries.get(19);
vehicleCode2 = entries.get(20);
}
/*
* Verifies accuracy of the zip code.
* @param zip the zip code to be verified
* @return true if zip is a valid zip code, false otherwise
*/
privateboolean verifyZip (String zip ){
if( zip.length()!=5)returnfalse;
for(int i =0; i < zip.length ...
2.Kernel need to be protected because non-root user execute kernel.pdfanitasahani11
2.
Kernel need to be protected because non-root user execute kernel code by using a syscall. In that
case, any number of users can access anything in the system, including hardware. Which means,
that a user with the correct program could ask the hardware to do anything it can possibly do.
Like erase others data or worse, modify them or use chargeable resources like network
bandwidth unnecessarily or even nefariously.
Solution
2.
Kernel need to be protected because non-root user execute kernel code by using a syscall. In that
case, any number of users can access anything in the system, including hardware. Which means,
that a user with the correct program could ask the hardware to do anything it can possibly do.
Like erase others data or worse, modify them or use chargeable resources like network
bandwidth unnecessarily or even nefariously..
1.C. Fate of the blastopore becomes the mouth.2.C. Endodermis Casp.pdfanitasahani11
1.C. Fate of the blastopore becomes the mouth.
2.C. Endodermis Casperian Strips made up of suberin and lignin, these materials make it water
impermeable
3.C. Fish having gills circulation, blood flow directly respiratory organ to body
Ambhibian, Birds, Reptile, Mammales having Pulmonary circuit for blood circulation.
4.E. All given options are common for plants and animals.
Solution
1.C. Fate of the blastopore becomes the mouth.
2.C. Endodermis Casperian Strips made up of suberin and lignin, these materials make it water
impermeable
3.C. Fish having gills circulation, blood flow directly respiratory organ to body
Ambhibian, Birds, Reptile, Mammales having Pulmonary circuit for blood circulation.
4.E. All given options are common for plants and animals..
More Related Content
Similar to package reservation; import java.util.; For Scanner Class .pdf
struct procedure { Date dateOfProcedure; int procedureID.pdfanonaeon
struct procedure
{
Date dateOfProcedure;
int procedureID;
int procedureProviderID;
};
Data.h
#include
#include
class Date
{
friend ostream& operator<<( ostream &, const Date & );
// allows easy output to a ostream
public:
Date( int m = 1, int d = 1, int y = 1900 ); // constructor, note the default values
void setDate( int, int, int ); // set the date const
Date &operator+=( int ); // add days, modify object
bool leapYear( int) const; // is this a leap year?
bool endOfMonth( int ) const; // is this end of month?
int getMonth ( ) const;
int getDay ( ) const;
int getYear ( ) const;
string getMonthString( ) const;
private:
int month;
int day;
int year;
static const int days[]; // array of days per month static const string monthName[]; // array of
month names
void helpIncrement();
// utility function
}; #endif Data.cpp // Member function definitions for Date
class in separate
date.cpp
#include
#include \"date.h\"
#include // Initialize static members at file scope; // one class-wide copy.
const int Date::days[] = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; const string
Date::monthName[] = { \"January\", \"February\", \"March\", \"April\", \"May\", \"June\",
\"July\", \"August\", \"September\", \"October\", \"November\", \"December\" };
// Date constructor
Date::Date(int m, int d, int y)
{
setDate(m, d, y); } // Set the date
void Date::setDate(int mm, int dd, int yy)
{
month = (mm >= 1 && mm <= 12) ? mm : 1; year = (yy >=1900&& yy <= 2100) ? yy
: 1900; // test for a leap year
if (month == 2 && leapYear(year)) day = (dd >= 1 && dd <= 29) ? dd : 1;
else
day =(dd >= 1 && dd <= days[month]) ? dd : 1;
} // Add a specific number of days to a date
const Date &Date::operator+=(int additionalDays)
{
for (int i = 0; i < additionalDays; i++) helpIncrement();
return *this; // enables cascading
} // If the year is leap year, return true; //
otherwise, return false
bool Date::leapYear(int testYear)
const
{
if (testYear % 400 == 0 || (testYear %100 != 0 && testYear % 4 == 0)) return true; // a
leap year
else
return false; // not a leap year
} // Determine if the day is the end of the month
bool Date::endOfMonth(int testDay)
const
{
if (month == 2 && leapYear(year))
return (testDay == 29); // last day of Feb. in leap year
else
return (testDay == days[month]);
} // Function to help increment the date
void Date::helpIncrement()
{
if (!endOfMonth(day))
{
// date is not at the end of the month
day++;
}
else if (month < 12)
{
// date is at the end of the month, but month < 12 day = 1; ++month;
}
else
{
// end of month and year: last day of the year
day = 1;
month = 1;
++year;
} }
// Overloaded output operator
ostream &operator<<(ostream& output, const Date &d)
{
output << d.monthName[d.month] << \' \' << d.day << \", \"<< d.year;
return output; // enables cascading
}
int Date::getMonth() const //
{
Public:
int month[20];
If(month[]!=”/0”)
Cout<<”Enter Month :-<>month;
Elseif (month[]<12)
{
Cout<>month[];
else
return month;
}
int Date::getDay() const //
{
Pu.
Production.javapublic class Production { Declaring instance.pdfsooryasalini
Production.java
public class Production {
//Declaring instance variables
private String title;
private String director;
private String writer;
//Parameterized constructor
public Production(String title, String director, String writer) {
super();
this.title = title;
this.director = director;
this.writer = writer;
}
//Setters and getters.
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getDirector() {
return director;
}
public void setDirector(String director) {
this.director = director;
}
public String getWriter() {
return writer;
}
public void setWriter(String writer) {
this.writer = writer;
}
//display() method which displays the Instance variable values
public void display()
{
System.out.println(\"Title: \" + this.title);
System.out.println(\"Director: \" + this.director);
System.out.println(\"Writer: \" + this.writer);
}
//toString() method is used to display the contents of an object
@Override
public String toString() {
return \"Title :\" + title + \"\ Director :\" + director
+ \"\ Writer :\" + writer;
}
}
___________________________________________
Film.java
public class Film extends Production{
//Declaring instance variables
private int boxOfficeGross;
//Parameterized constructor
public Film(String title, String director, String writer, int boxOfficeGross) {
super(title, director, writer);
this.boxOfficeGross = boxOfficeGross;
}
//Setters and getters.
public int getBoxOfficeGross() {
return boxOfficeGross;
}
public void setBoxOfficeGross(int boxOfficeGross) {
this.boxOfficeGross = boxOfficeGross;
}
//display() method which displays the Instance variable values
public void display()
{
System.out.println(\"BoxOfiiceGross: \" + this.boxOfficeGross);
}
//toString() method is used to display the contents of an object
@Override
public String toString() {
return super.toString()+\"\ BoxOfficeGross :\" + boxOfficeGross+\"\ \";
}
}
_______________________________________________
Play.java
public class Play extends Production {
//Declaring instance variables
private int performances;
//Parameterized constructor
public Play(String title, String director, String writer, int performances) {
super(title, director, writer);
this.performances = performances;
}
//Setters and getters.
public int getPerformances() {
return performances;
}
public void setPerformances(int performances) {
this.performances = performances;
}
//display() method which displays the Instance variable values
public void display()
{
System.out.println(\"Performances: \" + this.performances);
}
//toString() method is used to display the contents of an object
@Override
public String toString() {
return super.toString()+\"\ Performances :\" + performances+\"\ \";
}
}
_______________________________________________
Musical.java
public class BobsTerribleTests
{
public static void main(String[] args)
{
//Creating an Film Object by passing parameters
Film titanic = new Film(\"Titanic\", \"James Cameron\", \"James Cameron\.
operating system linux,ubuntu,Mac Geometri.pdfaquadreammail
//operating system linux,ubuntu,Mac
/*********************GeometricObject.java**********************/
public abstract class GeometricObject {
private String color = \"white\";
private boolean filled;
// default constructure
public GeometricObject() {
super();
// TODO Auto-generated constructor stub
}
// construct a Geometric Object
// parameterized constructure
public GeometricObject(String color, boolean filled) {
this.color = color;
this.filled = filled;
}
/** Getter method for color */
public String getColor() {
return color;
}
/** Setter method for color */
public void setColor(String color) {
this.color = color;
}
/**
* Getter method for filled. Since filled is boolean, so the gret method
* name is isFilled
*/
public boolean isFilled() {
return filled;
}
/** Setter method for filled */
public void setFilled(boolean filled) {
this.filled = filled;
}
/** Abstract method for FindArea */
public abstract double findArea();
/** Abstract method for findPerimeter */
public abstract double findPerimeter();
}
/*****************************Octagon.java**************/
public class Octagon extends GeometricObject implements Cloneable, Comparable {
private double side;
/** construct a Octagon with specified side */
public Octagon(double side) {
super();
this.side = side;
}
/** Implement the abstract method findArea in GeometricObject */
@Override
public double findArea() {
double area = (2 + 4 / Math.sqrt(2)) * side * side;
return area;
}
/** Implement the abstract method findArea in findPerimeter */
@Override
public double findPerimeter() {
double perimeter = 8 * side;
return perimeter;
}
/** Implement the compareTo method in Comparable interface */
@Override
public int compareTo(Object o) {
// TODO Auto-generated method stub
return 0;
}
public Object clone() throws CloneNotSupportedException {
return super.clone();
}
}
/*******************App.java*******************/
public class App {
public static void main(String[] args) {
Octagon a1 = new Octagon(5);//creating object of octagon
System.out.println(\"Area of a1 is \" + a1.findArea());
System.out.println(\"Perimeter of a1 is \" + a1.findPerimeter());
Object a2;
try {
a2 = a1.clone();
String result = (a1.compareTo(a2) == 0) ? \"a1 and its clone a2 have the same area\"
: \"a1 and its clone a2 have different areas\";
System.out.println(\"Compare a1 and its clone a2:\ \\t \" + result);
System.out.println(\"Hashcode of a1: \" + a1.hashCode());
System.out.println(\"Hashcode of a2: \" + a2.hashCode());
System.out.println(\"Displaying a1: \" + a1);
System.out.println(\"Displaying a2: \" + a2);
} catch (CloneNotSupportedException e) {
e.printStackTrace();
}
}
}
/*****************output***************/
gopal@gopal:~/Desktop/chegg$ javac GeometricObject.java
gopal@gopal:~/Desktop/chegg$ javac Octagon.java
gopal@gopal:~/Desktop/chegg$ javac App.java
gopal@gopal:~/Desktop/chegg$ java App
Area of a1 is 120.71067811865476
Perimeter of a1 is 40.0
Compare a1 and its clone a2:
a1 and its clone a2 have the same area
.
So Far I have these two classes but I need help with my persontest c.pdfarihantgiftgallery
So Far I have these two classes but I need help with my persontest class:
The next step is to add method calls for the accessor methods after each input:
//Reading and updating values
System.out.print(\"\ Enter Person Name: \");
person1.setPersonName(sc.nextLine());
System.out.println(\"You entered: \" + person1.getPersonName());
Call the accessor function each time you ask for input, after capturing that input. Then repeat for
a second Person, only this time call the constructor that takes the student id as a parameter.
7 import java.util.Scanner;
8
9 class PersonTest
10 {
11 //Main method
12 public static void main(String args[])
13 {
14 Scanner sc = new Scanner(System.in);
15
16 //Creating object
17 Persons_Information person1 = new Persons_Information();
18
19 //Reading and updating values
20 System.out.print(\"\ Enter Person Name: \");
21 person1.setPersonName(sc.nextLine());
22
23 System.out.print(\"\ Enter Current Address: \");
24 person1.setCurrentAdress(sc.nextLine());
25
26 System.out.print(\"\ Enter Permanent Address: \");
27 person1.setpermanentAdress(sc.nextLine());
28
29 System.out.print(\"\ Enter ID number: \");
30 person1.setIdNumber(sc.nextInt());
31
32 sc.nextLine();
33
34 System.out.print(\"\ Enter Birth Date: \");
35 person1.setBirthDate(sc.nextLine());
36
37
38 System.out.print(\"\ Enter Person Age: \");
39 person1.setPersonAge(sc.nextInt());
40
41
42 System.out.print(\"\ Enter Entry Year: \");
43 person1.setEntryYear(sc.nextInt());
44
45
46 System.out.print(\"\ Enter Total Years: \");
47 person1.setTotalYears(sc.nextInt());
48
49 //Printing person 1 details
50 System.out.println(\"\ Person 1: \ \" + person1.toString());
51 }
52 }
Solution
Persons_Information.java
public class Persons_Information {
//Declaring instance variables
private String personName;
private String currentAdress;
private String permanentAdress;
private int idNumber;
private String birthDate;
private int personAge;
private int entryYear;
private int totalYears;
//Zero argumented constructor
public Persons_Information()
{
}
//Parameterized constructor
public Persons_Information(int idNumber) {
this.idNumber = idNumber;
}
//Getters and setters
public String getPersonName() {
return personName;
}
public void setPersonName(String personName) {
this.personName = personName;
}
public String getCurrentAdress() {
return currentAdress;
}
public void setCurrentAdress(String currentAdress) {
this.currentAdress = currentAdress;
}
public String getPermanentAdress() {
return permanentAdress;
}
public void setPermanentAdress(String permanentAdress) {
this.permanentAdress = permanentAdress;
}
public int getIdNumber() {
return idNumber;
}
public void setIdNumber(int idNumber) {
this.idNumber = idNumber;
}
public String getBirthDate() {
return birthDate;
}
public void setBirthDate(String birthDate) {
this.birthDate = birthDate;
}
public int getPersonAge() {
return personAge;
}
public void setPersonAge(int personAge) {
this.personAge = personAge;
}
public int getEntryYe.
Tank Battle - A simple game powered by JMonkey engineFarzad Nozarian
A simple two player java-based game powered by JMonkey game engine which implements many standard object oriented design patterns such as Singleton, Composite, Strategy and etc.
I Have the following Java program in which converts Date to Words an.pdfallystraders
I Have the following Java program in which converts Date to Words and the only thing I have to
do now is add a boolean for a leap year. ( I am using Apache NetBeans) please explain where the
boolean goes.
Like this:
I need the code working with the boolean added, Thank you!!!
package a1_demo;
import java.util.Scanner;
public class MainApp {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.print("Welcome to the Date to Words Converter!\n\n");
while ( true ) {
// get user input
String str_MM_DD_YYYY = Validator.getString(
Validator.sc,
"Enter date in MM/DD/YYYY format: "
);
// convert text to ints:
// "11/22/3333" - > int, int int
String[] dateComponents = str_MM_DD_YYYY.split( "/" );
if ( dateComponents.length != 3 ) {
System.out.println("\t\t Bad input, please retry...");
continue;
}
int month = 0;
int day = 0;
int year = 0;
try {
month = Integer.parseInt(dateComponents[ 0 ]);
day = Integer.parseInt(dateComponents[ 1 ]);
year = Integer.parseInt(dateComponents[ 2 ]);
} catch ( java.lang.NumberFormatException ex ) {
System.out.println("\t\t numeric values are expected, please retry...");
continue;
}
Date2TextConverter converter = new Date2TextConverter( month, day, year );
System.out.print( converter.month2text() );
System.out.print( " " );
System.out.print( converter.day2text() );
System.out.print( " " );
System.out.print( converter.year2text() );
System.out.println();
}// endless while loop
}//main
}//class MainApp
package a1_demo;
public class Date2TextConverter {
//---------------------------------------
// data
//---------------------------------------
int month = 0;
int day = 0;
int year = 0;
//---------------------------------------
// constructors
//---------------------------------------
public Date2TextConverter(int month, int day, int year )
{
this.month = month;
this.day = day;
this.year = year;
}//Date2TextConverter
//---------------------------------------
// operations
//---------------------------------------
public String month2text()
{
switch( month )
{
case 1: return "Jan";
case 2: return "Feb";
case 3: return "Mar";
case 4: return"April";
case 5: return"May";
case 6: return"June";
case 7: return"July";
case 8: return"Aug";
case 9: return"Sep";
case 10: return"Oct";
case 11: return"Nov";
case 12: return"Dec";
//...
default:
return "Invalid Month";
}
}//month2text
public String day2text()
{
//return Integer.toString( day );
return number2words (day);
}//day2text
public String year2text()
{
int century = year / 100;
int yearInCentury = year % 100;
String centuryText = number2words( century );
String yearText = number2words( yearInCentury );
if ( yearInCentury < 10 ) {
return centuryText + " zero " + yearText;
} else {
return centuryText + " " + yearText;
}
}//year2text
private String number2words( int number ) {
// convert to text a number 0 through 99
if ( number < 20 ) {
// 0, 1, 2, 3, ..., 19
return zero2nineteen[ number ];
} else if ( number % 10 == 0 ) {
// 20, 30, 40, ... 90
return .
URGENTJavaPlease updated the already existing Java program and m.pdferremmfab
URGENT
Java
Please updated the already existing Java program and modify it with the steps below:
Where it says (\"text file path gets input into here\"); in the program link the path instead of that
with a text file with this data in it:
Copy and paste this and use as text file and input the path for the text file where it says \"text file
path gets input into here\".
2000/Alex/0110/0120/0
2001/Bill/0210/0220/0
2002/Chris/0310/0320/0
2003/Devon/0140/0420/0
2004/Eli/0510/0520/1
2005/Fred/0610/0620/2
2006/Gilbert/0710/0820/3
2007/Herbert/0910/0920/4
2008/Kim/1010/1020/5
###################################################################
import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;
//setting variables to string or int
public class Storm {
private int stormYear;
private int stormMag;
private String stormStart;
private String stormEnd;
private String stormName;
/**
* Constructor
* Storing all variables from text file
* @param stormName
* @param stormYear
* @param stormStart
* @param stormEnd
* @param stormMag
*/
public Storm(String stormName, int stormYear, String stormStart, String stormEnd, int
stormMag) {
this.stormName = stormName;
this.stormYear = stormYear;
this.stormStart = stormStart;
this.stormEnd = stormEnd;
this.stormMag = stormMag;
}
/**************************************************************/
/*Method: Get and Set */
/*Purpose: They serve to set&get values from class variables */
/*Parameters: */
/*String target: Storm Name */
/*Return: Storm Name */
/**************************************************************/
public String getStormName() {
return stormName;
}
/**
* @param stormName the stormName to set
*/
public void setStormName(String stormName) {
this.stormName = stormName;
}
/**
* @return the stormYear
*/
public int getStormYear() {
return stormYear;
}
/**
* @param stormYear the stormYear to set
*/
public void setStormYear(int stormYear) {
this.stormYear = stormYear;
}
/**
* @return the stormStart
*/
public String getStormStart() {
return stormStart;
}
/**
* @param stormStart the stormStart to set
*/
public void setStormStart(String stormStart) {
this.stormStart = stormStart;
}
//return the stormEnd
public String getStormEnd() {
return stormEnd;
}
//param stormEnd the stormEnd to set
public void setStormEnd(String stormEnd) {
this.stormEnd = stormEnd;
}
//return the stormMag
public int getStormMag() {
return stormMag;
}
/**
* @param stormMag the stormMag to set
*/
public void setStormMag(int stormMag) {
this.stormMag = stormMag;
}
/**************************************************************/
/*Method:String toString */
/*Purpose: convert to a string */
/*Parameters: */
/*String target: Storm Name */
/*Return: Storm Name */
/**************************************************************/
public String toString() {
String s = \"\ \" + getStormYear() + \"/ \" + getStormName() + \" \" ;
if(getStormMag() == -1){
s= s + \"(no info)\";
}
else {
if((getStormMag() == 0)){
s = s + \"(tropi.
I am having a hard time with this problem, can you help me #5. .pdfaroramobiles1
I am having a hard time with this problem, can you help me ???
#5. fill in the copy contructor so that it sets its data to a copy of the data of the Coin that is passed
in. Be sure that it creates a DEEP COPY. ( assuming that the Country class has a copy
constructor that creates one).
public class Coin {
//data
protected Country country;
protected String coinName;
protected int value;
// constructor
// default constructor
public Coin()
{
this.country=new Country(\"US\");
this.coinName=\"Quater\";
this.value=25;
}
//parametirezed constructor
public Coin(Country where,String theName,int theValue)
{
this.country=where;
this.coinName=theName;
this.value=theValue;
}
//copy constructor
public Coin(Coin another)
{
}
//methods
//getValue()-returns its value
public int getValue()
{
return value;
}
//toString-returns its String representation
public String tostring()
{
return coinName+\"with value\"+value;
}
}
Solution
// Copy constructor modified
public Coin(Coin another)
{
this.country=new Country(another.country); // call to the copy Constructor of Country class
this.coinName=another.coinName; // assigns instance member coinName of another object to
coinName of //current object
this.value=another.value; // assigns instance member value of another object to value of current
object
}.
Modify the Date class that was covered in the lecture which overload.pdfsaxenaavnish1
Modify the Date class that was covered in the lecture which overloaded the increment and stream
insertion operators.
The new version of the class should have the following overloaded operators:
(=) subtraction assignment operator :: subtracts the right operand from the left operand and
assigns the result to the left operand.
This operator should cause appropriate number of decrements to the object's 'day' member. It
also checks appropriate decrements to the 'month' and 'year' data members, if necessary.
(>>) cin 's stream extraction operator :: This operator should prompt the user for a date to be
stored in a Date object (you can specify your own format and prompt the user for the same).
Write a driver program and test the operators with the Date objects.
The program should have the following additional requirements:
The operator overloaded functions should be non-member functions.
Input validation (day, month) for the Date object.
The subtraction assignment operator (=) should work with end of month, end of year, and leap
year conditions as shown in the example output below.
Minimum three files (main.cpp, Date.h, Date.cpp). Submit your code as:
LastName_FirstName_Q2.zip (containing all files).
Example output:
Enter a date in format mm-dd-yyyy
01-01-2023
Date d1 is: January 1, 2023 // Check a valid date
Date (d1 -= 3) is: December 29, 2022 // Decrement by 3 days
Date d2 is: March 2, 2008
Date (d2-=2) is: February 29, 2008 // leap year has 29 days
Date.h
// Fig. 10.6: Date.h
// Date class definition with overloaded increment operators.
#ifndef DATE_H
#define DATE_H
#include
#include
class Date {
friend std::ostream& operator<<(std::ostream&, const Date&);
public:
Date(int m = 1, int d = 1, int y = 1900); // default constructor
void setDate(int, int, int); // set month, day, year
Date& operator++(); // prefix increment operator
Date operator++(int); // postfix increment operator
Date& operator+=(unsigned int); // add days, modify object
static bool leapYear(int); // is year a leap year?
bool endOfMonth(int) const; // is day at the end of month?
private:
unsigned int month;
unsigned int day;
unsigned int year;
static const std::array days; // days per month
void helpIncrement(); // utility function for incrementing date
};
#endif
Date.cpp
#include
#include
#include "Date.h"
using namespace std;
// initialize static member; one classwide copy
const array Date::days{
0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
// Date constructor
Date::Date(int month, int day, int year) {
setDate(month, day, year);
}
// set month, day and year
void Date::setDate(int mm, int dd, int yy) {
if (mm >= 1 && mm <= 12) {
month = mm;
}
else {
throw invalid_argument{"Month must be 1-12"};
}
if (yy >= 1900 && yy <= 2100) {
year = yy;
}
else {
throw invalid_argument{"Year must be >= 1900 and <= 2100"};
}
// test for a leap year
if ((month == 2 && leapYear(year) && dd >= 1 && dd <= 29) ||
(dd >= 1 && dd <= days[month])) {
day = dd;
}
else {
throw invalid_argument{
"Da.
I have the following code and I need to know why I am receiving the .pdfezzi552
Edwards Manufacturing Company purchases two component parts from three different suppliers.
The suppliers have limited capacity, and no one supplier can meet all the company’s needs. In
addition, the suppliers charge different prices for the components. Component price data (in
price per unit) are as follows:
Each supplier has a limited capacity in terms of the total number of components it can supply.
However, as long as Edwards provides sufficient advance orders, each supplier can devote its
capacity to component 1, component 2, or any combination of the two components, if the total
number of units ordered is within its capacity. Supplier capacities are as follows:
If the Edwards production plan for the next period includes 1000 units of component 1 and 800
units of component 2, what purchases do you recommend? That is, how many units of each
component should be ordered from each supplier? Round your answers to the nearest whole
number.
What is the total purchase cost for the components? Round your answer to the nearest dollar.
$ ????SupplierComponent1231$11$10$132$10$11$11
Solution
For component 1:
supplier 2 have minimum cost and capacity 1050.
So all the component 1 (1000) can be purchased from supplier 2.
So, supplier 2 have 50 more capacity.
Now, supplier 1 have minimum cost for component 2 and have capacity of 650.
so, number of component 2 from supplier1 can be 650.
Now, we need 150 more component 2.
supplier 2 and 3 have same cost for component 2.
supllier have only 50 capacity now and supplier have 850.
So, 150 component 2 can be purchased from supplier 3.
Let y be the number of components fromSupplier123TotalcostComponent
1010000100010000Component 265001508008150Total cost18150.
import java.util.;import acm.program.;public class FlightPla.pdfanushasarees
import java.util.*;
import acm.program.*;
public class FlightPlanner extends ConsoleProgram {
/* Private instance variables */
private FlightDB flights; //creates a new database
private ArrayList enteredCities = new ArrayList(); //keeps track of entered cities
private String firstCity; //keeps track of the first city entered by the user
public void init() {
//passes the text file to the database to read and parse
flights = new FlightDB(\"flights.txt\");
}
public void run() {
welcome();
askForFistCity();
askForMoreCities();
printFinalRoute();
}
/* Welcomes the user */
private void welcome() {
println(\"Welcome to Flight Planner\");
println(\"Here is a list of all the cities in our database\");
Iterator it = flights.getCities();
while(it.hasNext()) {
println(\" \" + it.next());
}
println(\"Let\'s plan a round-trip route!\");
}
/* asks the user for the starting city and prints out
* all the possible destination cities for that city */
private void askForFistCity() {
while(true) {
firstCity = readLine(\"Enter the starting city: \");
if(flights.ContainsKey(firstCity)) {
enteredCities.add(firstCity);
break;
}
else{
println(\"You can\'t get to that city by a direct flight.\");
println(\"Here is a list of all the cities in our database\");
Iterator it = flights.getCities();
while(it.hasNext()) {
println(\" \" + it.next());
}
}
}
println(\"From \" + firstCity + \" you can fly directly to:\");
Iterator it = flights.findRoute(firstCity);
while(it.hasNext()) {
println(\" \" + it.next());
}
}
/* asks the user for the cities he/she wants to fly to,
* and prints out possible destination cities for each city
* until the user enters the starting city */
private void askForMoreCities() {
String city = firstCity;
String lastCity = city;
while(true) {
city = readLine(\"Where do you want to go from \" + city + \"? \");
if(city.equals(firstCity)) {
break;
}
if(flights.ContainsKey(city) == true) {
lastCity = city;
enteredCities.add(city);
}
else{
city = lastCity;
println(\"You can\'t get to that city by a direct flight.\");
}
println(\"From \" + city + \" you can fly directly to:\");
Iterator it = flights.findRoute(city);
while(it.hasNext()) {
println(\" \" + it.next());
}
}
}
/* prints out the chosen route */
private void printFinalRoute() {
println(\"The route you\'ve chosen is\");
String route = enteredCities.get(0);
for(int i = 1; i \" + enteredCities.get(i);
}
route += \" -> \" + enteredCities.get(0);
println(route);
}
}
import acm.program.*;
public class FlightPlanner extends ConsoleProgram {
/* Private instance variables */
private FlightDB flights; //creates a new database
private ArrayList enteredCities = new ArrayList(); //keeps track of entered cities
private String firstCity; //keeps track of the first city entered by the user
public void init() {
//passes the text file to the database to read and parse
flights = new FlightDB(\"flights.txt\");
}
public void run() {
welcome();
askForFistCity();
askForMoreCities();
printFinalRoute();
}
/* Welcomes the use.
proj6/Collision.javaproj6/Collision.javapackage proj6;
import java.util.ArrayList;
/**
* Collision objects represent individual collisions occuring on NYC streets.
* Each object contains information regarding the time, location, number
* of injuries and fatalities and types of involved vehicles.
* @author Joanna K.
*
*/
publicclassCollisionimplementsComparable<Collision>{
staticprivateSortOrder sortOrder =SortOrder.ZIP;
privateString date;
privateString time;
privateString borough;
privateString zip;
privateint personsInjured;
privateint personsKilled;
privateint pedestriansInjured;
privateint pedestriansKilled;
privateint cyclistsInjured;
privateint cyclistsKilled;
privateint motoristsInjured;
privateint motoristsKilled;
privateString vehicleCode1;
privateString vehicleCode2;
privateString uniqueKey;
/**
* Creates a Collision object given an array of entries.
* There should be 21 string entries in the following order:
* date
* time
* borough
* zip
* lattitude^
* longitude ^
* on street name^
* cross street name ^
* personsInjured
* personsKilled
* pedestriansInjured
* pedestriansKilled
* cyclistsInjured
* cyclistsKilled
* motoristsInjured
* motoristsKilled
* contributing factor vehicle 1^
* contributing factor vehicle 2^
* uniqueKey
* vehicleCode1
* vehicleCode2
* The entries indicated with ^ are not used.
*
* @param entries an array of entries containing information about the
* collision
* @throws IllegalArgumentException when the Collision object cannot be created
* due to errors or incompleteness of the entries parameter
*/
publicCollision(ArrayList<String> entries )throwsIllegalArgumentException{
date = entries.get(0);
time = entries.get(1);
borough = entries.get(2);
zip = entries.get(3);
if(!verifyZip(zip)){
thrownewIllegalArgumentException("invalid zip");
}
try{
personsInjured =Integer.parseInt(entries.get(8));
personsKilled =Integer.parseInt(entries.get(9));
pedestriansInjured =Integer.parseInt(entries.get(10));
pedestriansKilled =Integer.parseInt(entries.get(11));
cyclistsInjured =Integer.parseInt(entries.get(12));
cyclistsKilled =Integer.parseInt(entries.get(13));
motoristsInjured =Integer.parseInt(entries.get(14));
motoristsKilled =Integer.parseInt(entries.get(15));
}
catch(NumberFormatException ex ){
thrownewIllegalArgumentException( ex.getMessage());
}
uniqueKey = entries.get(18);
vehicleCode1 = entries.get(19);
vehicleCode2 = entries.get(20);
}
/*
* Verifies accuracy of the zip code.
* @param zip the zip code to be verified
* @return true if zip is a valid zip code, false otherwise
*/
privateboolean verifyZip (String zip ){
if( zip.length()!=5)returnfalse;
for(int i =0; i < zip.length ...
2.Kernel need to be protected because non-root user execute kernel.pdfanitasahani11
2.
Kernel need to be protected because non-root user execute kernel code by using a syscall. In that
case, any number of users can access anything in the system, including hardware. Which means,
that a user with the correct program could ask the hardware to do anything it can possibly do.
Like erase others data or worse, modify them or use chargeable resources like network
bandwidth unnecessarily or even nefariously.
Solution
2.
Kernel need to be protected because non-root user execute kernel code by using a syscall. In that
case, any number of users can access anything in the system, including hardware. Which means,
that a user with the correct program could ask the hardware to do anything it can possibly do.
Like erase others data or worse, modify them or use chargeable resources like network
bandwidth unnecessarily or even nefariously..
1.C. Fate of the blastopore becomes the mouth.2.C. Endodermis Casp.pdfanitasahani11
1.C. Fate of the blastopore becomes the mouth.
2.C. Endodermis Casperian Strips made up of suberin and lignin, these materials make it water
impermeable
3.C. Fish having gills circulation, blood flow directly respiratory organ to body
Ambhibian, Birds, Reptile, Mammales having Pulmonary circuit for blood circulation.
4.E. All given options are common for plants and animals.
Solution
1.C. Fate of the blastopore becomes the mouth.
2.C. Endodermis Casperian Strips made up of suberin and lignin, these materials make it water
impermeable
3.C. Fish having gills circulation, blood flow directly respiratory organ to body
Ambhibian, Birds, Reptile, Mammales having Pulmonary circuit for blood circulation.
4.E. All given options are common for plants and animals..
1. a. -8 to 4 is 12 unitsb. D to B is 8 unitsc. idk what that de.pdfanitasahani11
1. a. -8 to 4 is 12 units
b. D to B is 8 units
c. idk what that definition is
Solution
1. a. -8 to 4 is 12 units
b. D to B is 8 units
c. idk what that definition is.
1. Confidential or privileged information cannot be denied to the co.pdfanitasahani11
1. Confidential or privileged information cannot be denied to the courts. Under common law,
CPAs do not have the right to withhold information from the courts on the grounds that the
information is privileged.
2. Cullen should be made liable for negligence as due care was not taken in auditing the
valuation of securities. Also, audit was not planned in well advance due to which Cullen was
uncertain about correct valuation of securities.
3. Joanie cannot be held in this case. A partner cannot be held liable for the professional
misconduct of other partner. If she had been involved in the audit with other partner, then she
could have been made liable.
4. Hockaday is convinced that he has followed all standards and procedures in performing the
audit. Hence, he can use his Non-negligent performance supported by hi s audit documentation
as a tool to defend himself in the lawsuit.
5. The external auditors of Eastman Kodak should have assessed the existence of Going concern
in the reporting period. Thereafter, explanatory paragraph should have been included in the audit
report in case of non-existence of going concern.
Solution
1. Confidential or privileged information cannot be denied to the courts. Under common law,
CPAs do not have the right to withhold information from the courts on the grounds that the
information is privileged.
2. Cullen should be made liable for negligence as due care was not taken in auditing the
valuation of securities. Also, audit was not planned in well advance due to which Cullen was
uncertain about correct valuation of securities.
3. Joanie cannot be held in this case. A partner cannot be held liable for the professional
misconduct of other partner. If she had been involved in the audit with other partner, then she
could have been made liable.
4. Hockaday is convinced that he has followed all standards and procedures in performing the
audit. Hence, he can use his Non-negligent performance supported by hi s audit documentation
as a tool to defend himself in the lawsuit.
5. The external auditors of Eastman Kodak should have assessed the existence of Going concern
in the reporting period. Thereafter, explanatory paragraph should have been included in the audit
report in case of non-existence of going concern..
Whales are mammals that breathe into the lungs. Whales contain blow .pdfanitasahani11
Whales are mammals that breathe into the lungs. Whales contain blow hole or nostril on the top
or back of their head. When whales are in water, the blow hole is covered with a muscular flap.
When they come to water surface, the flap is opened and exhale the air which occurs as a blow or
stream of misty air. Then they inhale the air. The process may take place few seconds. Again, the
blowhole is closed with the flap and indicates that whale is in relaxed position. Since, whales
cannot breathe through the mouth like other mammals because their esophagus is not connected
to lungs. The blow hole leads to trachea and from the hole, the air enters the lungs. The hole is
opened only when the whales come onto water surface and hole is closed with muscular flap
when they are in water and relaxed.
Solution
Whales are mammals that breathe into the lungs. Whales contain blow hole or nostril on the top
or back of their head. When whales are in water, the blow hole is covered with a muscular flap.
When they come to water surface, the flap is opened and exhale the air which occurs as a blow or
stream of misty air. Then they inhale the air. The process may take place few seconds. Again, the
blowhole is closed with the flap and indicates that whale is in relaxed position. Since, whales
cannot breathe through the mouth like other mammals because their esophagus is not connected
to lungs. The blow hole leads to trachea and from the hole, the air enters the lungs. The hole is
opened only when the whales come onto water surface and hole is closed with muscular flap
when they are in water and relaxed..
This site provides illustrative experience in the use of Excel for d.pdfanitasahani11
This site provides illustrative experience in the use of Excel for data summary, presentation, and
for other basic statistical analysis. I believe the popular use of Excel is on the areas where Excel
really can excel. This includes organizing data, i.e. basic data management, tabulation and
graphics. For real statistical analysis on must learn using the professional commercial statistical
packages such as SAS, and SPSS.
Microsoft Excel 2000 (version 9) provides a set of data analysis tools called the Analysis
ToolPak which you can use to save steps when you develop complex statistical analyses. You
provide the data and parameters for each analysis; the tool uses the appropriate statistical macro
functions and then displays the results in an output table. Some tools generate charts in addition
to output tables.
If the Data Analysis command is selectable on the Tools menu, then the Analysis ToolPak is
installed on your system. However, if the Data Analysis command is not on the Tools menu, you
need to install the Analysis ToolPak by doing the following:
Step 1: On the Tools menu, click Add-Ins.... If Analysis ToolPak is not listed in the Add-Ins
dialog box, click Browse and locate the drive, folder name, and file name for the Analysis
ToolPak Add-in — Analys32.xll — usually located in the Program Files\\Microsoft
Office\\Office\\Library\\Analysis folder. Once you find the file, select it and click OK.
Step 2: If you don\'t find the Analys32.xll file, then you must install it.
Insert your Microsoft Office 2000 Disk 1 into the CD ROM drive.
Select Run from the Windows Start menu.
Browse and select the drive for your CD. Select Setup.exe, click Open, and click OK.
Click the Add or Remove Features button.
Click the + next to Microsoft Excel for Windows.
Click the + next to Add-ins.
Click the down arrow next to Analysis ToolPak.
Select Run from My Computer.
Select the Update Now button.
Excel will now update your system to include Analysis ToolPak.
Launch Excel.
On the Tools menu, click Add-Ins... - and select the Analysis ToolPak check box.
Step 3: The Analysis ToolPak Add-In is now installed and Data Analysis... will now be
selectable on the Tools menu.
Microsoft Excel is a powerful spreadsheet package available for Microsoft Windows and the
Apple Macintosh. Spreadsheet software is used to store information in columns and rows which
can then be organized and/or processed. Spreadsheets are designed to work well with numbers
but often include text. Excel organizes your work into workbooks; each workbook can contain
many worksheets; worksheets
are used to list and analyze data .
Excel is available on all public-access PCs (i.e., those, e.g., in the Library and PC Labs). It can
be opened either by selecting Start - Programs - Microsoft Excel or by clicking on the Excel
Short Cut which is either on your desktop, or on any PC, or on the Office Tool bar.
Opening a Document:
Click on File-Open (Ctrl+O) to open/retrieve an existing workbook; change the d.
The conch symbolizes social order, respect and power. When the boys .pdfanitasahani11
The conch symbolizes social order, respect and power. When the boys hold meetings around the
camp fire, only the speaker who is holding the conch may address the crowd. The speaker with
the conch is supposed to be respected by the group and heard. In addition, usually the older boys
are the ones seeking to hold the conch in order to gain the right to speak. With the struggle to
obtain the conch, the author is commenting in general about the quest of politicians for power.
What will men do to gain popularity and votes in a society? What will they do to be heard by the
masses? In the novel, providing food and fire for the boys makes a leader more popular. In the
real world, providing funding for public works and social welfare projects in a democratic
society makes a politician more popular.
By the time the conch is destroyed, the boys\' civilized world has also become unglued. One of
the boys was killed by a fire which got out of control and swept through the island. More death
and mayhem ensues. Controlling fire, food and the higher ground on the island are the goals of
the leaders. They need to be able to control all of these things in order to keep their power over
the group and maintain some semblance of an organized society. The author uses the story to
comment on adults\' quest for leadership and power, and society\'s response to its leaders.
Solution
The conch symbolizes social order, respect and power. When the boys hold meetings around the
camp fire, only the speaker who is holding the conch may address the crowd. The speaker with
the conch is supposed to be respected by the group and heard. In addition, usually the older boys
are the ones seeking to hold the conch in order to gain the right to speak. With the struggle to
obtain the conch, the author is commenting in general about the quest of politicians for power.
What will men do to gain popularity and votes in a society? What will they do to be heard by the
masses? In the novel, providing food and fire for the boys makes a leader more popular. In the
real world, providing funding for public works and social welfare projects in a democratic
society makes a politician more popular.
By the time the conch is destroyed, the boys\' civilized world has also become unglued. One of
the boys was killed by a fire which got out of control and swept through the island. More death
and mayhem ensues. Controlling fire, food and the higher ground on the island are the goals of
the leaders. They need to be able to control all of these things in order to keep their power over
the group and maintain some semblance of an organized society. The author uses the story to
comment on adults\' quest for leadership and power, and society\'s response to its leaders..
The bone marrow is the wellspring of numerous immune and blood cells.pdfanitasahani11
The bone marrow is the wellspring of numerous immune and blood cells in the solid grown-up
creature. In the event that the bone is part the long way, a stamped contrast in tissue is taken
note. Part of the tissue is red, which is the wellspring of red and white platelets. The other bit is
yellow fat tissue that is idle. Amid a contamination, the yellow marrow can be reactivated to
wind up red marrow to help in the generation of bigger quantities of safe cells.
In the grown-up creature, every single insusceptible cell begin from hematopoietic
undifferentiated organisms situated in the bone marrow. Stems cells always isolate and separate
into different sorts of resistant cells affected by cytokines. the starting point of the cells of the
resistant framework. Cytokines are little flagging proteins that direct the conduct of the cells of
the body. The bone marrow is at last in charge of the union of eight sorts of cells: red platelets,
platelets, neutrophils, basophils, eosinophils, pole cells, monocytes/macrophages, T lymphocytes
and B lymphocytes. Some of these cell sorts develop in the bone marrow itself, while others
relocate through the circulatory framework and experience last development in different tissues.
Now, we will investigate quickly at a portion of the components of the cells made in the bone
marrow as a prologue to their capacity. You will take in more insights about every resistant cell
sort later when we cover particular insusceptible reactions..
The real cell sort made by the bone marrow is red platelets. Platelets likewise shape in the bone
marrow and help with development of blood clumps taking after any sort of harm. Neither of
these cell sorts assumes a part in the resistant reaction, yet we specify them here in light of the
fact that they likewise start from bone marrow undifferentiated organisms and are basic segments
of the blood.
Polymorphonuclear granulocytes is the general term given to neutrophils, eosinophils and
basophils. The primary portion of the name portrays the presence of the core that is by all
accounts split into various diverse flaps. In actuality, the core is coterminous, yet contains
numerous infoldings, which give it a polynuclear appearance. Whatever is left of the name
originates from the presence of the cytoplasm, which looks spotted. The cytoplasm is loaded
with granules that contain mixes and chemicals imperative in satisfying the capacity of every cell
sort. Polymorphonuclear granulocytes make up 50-70% of the white platelets found in blood.
They last just around three days and must be supplanted at a rate of 80 million cells for each
moment.
Neutrophils are the most well-known sort of polymorphonuclear cells, making up 90% of
granulocytes in the blood. These cells work as phagocytes in assaulting and decimating
irresistible specialists. We will cover their parts in more detail when we examine phagocytes.
Eosinophils make up 2-5% of granulocytes in the blood, however this number can rise
signifi.
Stanley Miller experiment explains the origin and evolution of earth.pdfanitasahani11
Stanley Miller experiment explains the origin and evolution of earth. he explains how life is
formed from the organic matter. Stanley Miller has created an atmosphere of early earth in lab
with water, chemicals like methane, ammonia , hydrogen, electric lightning etc. and showed that
organic molecule like amino acid could be formed from inorganic precursors. Life requires
carbon containing organic molecules and thus he explined the origin of life.
Solution
Stanley Miller experiment explains the origin and evolution of earth. he explains how life is
formed from the organic matter. Stanley Miller has created an atmosphere of early earth in lab
with water, chemicals like methane, ammonia , hydrogen, electric lightning etc. and showed that
organic molecule like amino acid could be formed from inorganic precursors. Life requires
carbon containing organic molecules and thus he explined the origin of life..
public class DecimalToBinary { public void printBinaryFormat(in.pdfanitasahani11
public class DecimalToBinary {
public void printBinaryFormat(int number){
int binary[] = new int[25];
int index = 0;
while(number > 0){
binary[index++] = number%2;
number = number/2;
}
for(int i = index-1;i >= 0;i--){
System.out.print(binary[i]);
}
}
public static void main(String a[]){
DecimalToBinary dtb = new DecimalToBinary();
dtb.printBinaryFormat(25);
}
}
Solution
public class DecimalToBinary {
public void printBinaryFormat(int number){
int binary[] = new int[25];
int index = 0;
while(number > 0){
binary[index++] = number%2;
number = number/2;
}
for(int i = index-1;i >= 0;i--){
System.out.print(binary[i]);
}
}
public static void main(String a[]){
DecimalToBinary dtb = new DecimalToBinary();
dtb.printBinaryFormat(25);
}
}.
Traffic intersection is a piece of transportation infrastructure wha.pdfanitasahani11
Traffic intersection is a piece of transportation infrastructure what we think the most dengerous.
Intersection is an area shared by two or more roads. This area is designated for the vehicles to
turn to different directions to reach their desired destinations. Its main function is to guide
vehicles to their respective directions. Traffic intersections are complex locations on any
highway. So, it become obvious to provide an intersection. There will be crosswalks too, so
design of the signal duration must be very accurate. Short term- We can provide overbridges or
subways for the pedestrians instead of crosswalk. Long term- Signaled Intersections can be
replaced by Rotary or diamond intersection for smooth traffic. Safety improvement is a balance.
We have to take care of both pedestrian and vehicles. If we provide non-signaling intersection
then there will be no crosswalk for the pedestrian. But this can\'t be implemented in a busy street
junctions. So we provide Subways. Now due to no signaling, traffic flow will be increase which
may lead more vehicular accidents. An improvement first introduced based on previous records
and forecasting. For measures we will track traffic data, no. of accidents etc. Comparison of
present situation with the past, why it become necessary to improve that piece, will actually be a
standard mesure.
Solution
Traffic intersection is a piece of transportation infrastructure what we think the most dengerous.
Intersection is an area shared by two or more roads. This area is designated for the vehicles to
turn to different directions to reach their desired destinations. Its main function is to guide
vehicles to their respective directions. Traffic intersections are complex locations on any
highway. So, it become obvious to provide an intersection. There will be crosswalks too, so
design of the signal duration must be very accurate. Short term- We can provide overbridges or
subways for the pedestrians instead of crosswalk. Long term- Signaled Intersections can be
replaced by Rotary or diamond intersection for smooth traffic. Safety improvement is a balance.
We have to take care of both pedestrian and vehicles. If we provide non-signaling intersection
then there will be no crosswalk for the pedestrian. But this can\'t be implemented in a busy street
junctions. So we provide Subways. Now due to no signaling, traffic flow will be increase which
may lead more vehicular accidents. An improvement first introduced based on previous records
and forecasting. For measures we will track traffic data, no. of accidents etc. Comparison of
present situation with the past, why it become necessary to improve that piece, will actually be a
standard mesure..
There is actually a few differences. Firstly, a p.pdfanitasahani11
There is actually a few differences. Firstly, a pure substance can be an element or
compound. A compound is a subtance where the elements made up of it are bonded by chemical
bonds, either ionic or covalent bond. A mixture may consist of a combination of elements or
compound, where there is no forces of attraction between them. Pure substance: Carbon dioxide,
water, sodium chloride. Mixture: Alloy like brass (zinc & copper), chalky water (calcium
carbonate and water). Pure substance has fixed melting and boiling point whereas mixture has a
range of melting and boiling point due to presence of impurities. Pure substance has fixed
composition by mass but mixture has varying degree of composition. Pure substance cannot be
separated into other substance by physical means like distillation, filtration unlike a mixture.
Pure substance has to be separated by chemical means like electrolysis to it\'s constituent parts.
Solution
There is actually a few differences. Firstly, a pure substance can be an element or
compound. A compound is a subtance where the elements made up of it are bonded by chemical
bonds, either ionic or covalent bond. A mixture may consist of a combination of elements or
compound, where there is no forces of attraction between them. Pure substance: Carbon dioxide,
water, sodium chloride. Mixture: Alloy like brass (zinc & copper), chalky water (calcium
carbonate and water). Pure substance has fixed melting and boiling point whereas mixture has a
range of melting and boiling point due to presence of impurities. Pure substance has fixed
composition by mass but mixture has varying degree of composition. Pure substance cannot be
separated into other substance by physical means like distillation, filtration unlike a mixture.
Pure substance has to be separated by chemical means like electrolysis to it\'s constituent parts..
Hg^2+ is soft acid and thus akin to bind to soft .pdfanitasahani11
Hg^2+ is soft acid and thus akin to bind to soft base S^2- to form HgS. The
relatively harder acids Zn^2+ and Cd^2+ are more inclined to react with hard bases such as
CO3^2-, O^2- to form carbonates and oxides.
Solution
Hg^2+ is soft acid and thus akin to bind to soft base S^2- to form HgS. The
relatively harder acids Zn^2+ and Cd^2+ are more inclined to react with hard bases such as
CO3^2-, O^2- to form carbonates and oxides..
HCl dissociates into H+ and Cl- in solution. The .pdfanitasahani11
HCl dissociates into H+ and Cl- in solution. The H+ interacts with H2O to make
H3O+. Thus, when there\'s extra acid in solution, there\'s extra H3O+ in solution. This pushes
the reaction to the left. Make sense? I hope so! :)
Solution
HCl dissociates into H+ and Cl- in solution. The H+ interacts with H2O to make
H3O+. Thus, when there\'s extra acid in solution, there\'s extra H3O+ in solution. This pushes
the reaction to the left. Make sense? I hope so! :).
Unit 8 - Information and Communication Technology (Paper I).pdfThiyagu K
This slides describes the basic concepts of ICT, basics of Email, Emerging Technology and Digital Initiatives in Education. This presentations aligns with the UGC Paper I syllabus.
How to Split Bills in the Odoo 17 POS ModuleCeline George
Bills have a main role in point of sale procedure. It will help to track sales, handling payments and giving receipts to customers. Bill splitting also has an important role in POS. For example, If some friends come together for dinner and if they want to divide the bill then it is possible by POS bill splitting. This slide will show how to split bills in odoo 17 POS.
Synthetic Fiber Construction in lab .pptxPavel ( NSTU)
Synthetic fiber production is a fascinating and complex field that blends chemistry, engineering, and environmental science. By understanding these aspects, students can gain a comprehensive view of synthetic fiber production, its impact on society and the environment, and the potential for future innovations. Synthetic fibers play a crucial role in modern society, impacting various aspects of daily life, industry, and the environment. ynthetic fibers are integral to modern life, offering a range of benefits from cost-effectiveness and versatility to innovative applications and performance characteristics. While they pose environmental challenges, ongoing research and development aim to create more sustainable and eco-friendly alternatives. Understanding the importance of synthetic fibers helps in appreciating their role in the economy, industry, and daily life, while also emphasizing the need for sustainable practices and innovation.
Read| The latest issue of The Challenger is here! We are thrilled to announce that our school paper has qualified for the NATIONAL SCHOOLS PRESS CONFERENCE (NSPC) 2024. Thank you for your unwavering support and trust. Dive into the stories that made us stand out!
Palestine last event orientationfvgnh .pptxRaedMohamed3
An EFL lesson about the current events in Palestine. It is intended to be for intermediate students who wish to increase their listening skills through a short lesson in power point.
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptxEduSkills OECD
Andreas Schleicher presents at the OECD webinar ‘Digital devices in schools: detrimental distraction or secret to success?’ on 27 May 2024. The presentation was based on findings from PISA 2022 results and the webinar helped launch the PISA in Focus ‘Managing screen time: How to protect and equip students against distraction’ https://www.oecd-ilibrary.org/education/managing-screen-time_7c225af4-en and the OECD Education Policy Perspective ‘Students, digital devices and success’ can be found here - https://oe.cd/il/5yV
package reservation; import java.util.; For Scanner Class .pdf
1. package reservation;
import java.util.*; //For Scanner Class
import java.time.*; //For LocalDate
import java.time.format.*; //For DateTimeFormatter
public class Reservation
{
double perNight = 105.00, finalAmt;
long noDays;
int m, d, y;
LocalDate std, end;
//Sets the Arrival date inputed by the user
void setArrivalDate(LocalDate arrivalDate)
{
std = arrivalDate;
}
//Sets the Departure date inputed by the user
void setDepartureDate(LocalDate departureDate)
{
end = departureDate;
}
//Returns the Arrival date
LocalDate getArrivalDate()
{
return std;
}
//Returns the Departure date
LocalDate getDepartureDate()
{
return end;
2. }
//Formats the Arrival date as per the requirement given question
String getArrivalDateFormatted()
{
String stdFormat;
stdFormat = "Arrival Date: " + std.getMonth() + " " + String.valueOf(std.getDayOfMonth())
+ ", " + String.valueOf(std.getYear());
return stdFormat;
}
//Formats the Departure date as per the requirement given question
String getDepartureDateFormatted()
{
String stdFormat;
stdFormat = "Departure Date: " + end.getMonth() + " " +
String.valueOf(end.getDayOfMonth()) + ", " + String.valueOf(end.getYear());
return stdFormat;
}
//Returns the Price per night as per the format
String getPricePerNightFormatted()
{
String pr = "Price: $" + String.valueOf(perNight) + " per night";
return pr;
}
//Returns the number of nights
long getNumberOfNights()
{
//toEpochDay() returns number of days
noDays = end.toEpochDay() - std.toEpochDay();
return noDays;
}
//Calculates final Amount to be paid
3. double getTotalPrice()
{
finalAmt = (double)getNumberOfNights() * perNight;
return finalAmt;
}
//Returns the Total amount to be paid as per the format given in the question
String getTotalPriceFormatted()
{
String finA = "Total price: $" + String.valueOf(getTotalPrice()) + " for " +
String.valueOf(getNumberOfNights()) + " night" ;
return finA;
}
//Accepts the Arrival date and Departure date from console
void accept()
{
//Creates object of LocaleDate
LocalDate std1, end1;
//Creates the Date Time Formater object and applies Format Style
//SHORT in mm/dd/yy format
DateTimeFormatter fmt = DateTimeFormatter.ofLocalizedDate(FormatStyle.SHORT);
//Creates Scanner class object to accept data from console
Scanner s = new Scanner(System.in);
System.out.println("Enter starting date mm/dd/yyyy: ");
System.out.println("Enter the arrival month (1-12):");
m = s.nextInt(); //Accept data in integer format
System.out.println("Enter the arrival day (1-31):") ;
d = s.nextInt();
System.out.println("Enter the arrival year:") ;
y = s.nextInt();
//Initializes the LocalDate object for Arrival date
4. std1 = LocalDate.of(y, m, d);
//Sets the SHORT date format
fmt.format(std1);
//Assigns Arrival date to class data member
setArrivalDate(std1);
System.out.println("Enter ending date mm/dd/yyyy: ");
System.out.println("Enter the departure month (1-12):");
m = s.nextInt(); //Accept data in integer format
System.out.println("Enter the departure day (1-31):") ;
d = s.nextInt();
System.out.println("Enter the departure year:") ;
y = s.nextInt();
//Initializes the LocalDate object for Departure date
end1 = LocalDate.of(y, m, d);
//Sets the SHORT date format
fmt.format(std1);
//Assigns Departure date to class data member
setDepartureDate(end1);
}
public static void main(String[] args)
{
char ch;
System.out.println("Welcome to the Reservation Calculator ");
//Creates Reservation class object
Reservation cc = new Reservation();
Scanner s = new Scanner(System.in);
//Loops till Y is pressed
do
6. y
Enter starting date mm/dd/yyyy:
Enter the arrival month (1-12):
7
Enter the arrival day (1-31):
20
Enter the arrival year:
2016
Enter ending date mm/dd/yyyy:
Enter the departure month (1-12):
7
Enter the departure day (1-31):
27
Enter the departure year:
2016
Arrival Date: JULY 20, 2016
Departure Date: JULY 27, 2016
Price: $105.0 per night
Total price: $735.0 for 7 night
Would you like to continue? (y/n)
n
Solution
package reservation;
import java.util.*; //For Scanner Class
import java.time.*; //For LocalDate
import java.time.format.*; //For DateTimeFormatter
public class Reservation
{
double perNight = 105.00, finalAmt;
long noDays;
int m, d, y;
LocalDate std, end;
7. //Sets the Arrival date inputed by the user
void setArrivalDate(LocalDate arrivalDate)
{
std = arrivalDate;
}
//Sets the Departure date inputed by the user
void setDepartureDate(LocalDate departureDate)
{
end = departureDate;
}
//Returns the Arrival date
LocalDate getArrivalDate()
{
return std;
}
//Returns the Departure date
LocalDate getDepartureDate()
{
return end;
}
//Formats the Arrival date as per the requirement given question
String getArrivalDateFormatted()
{
String stdFormat;
stdFormat = "Arrival Date: " + std.getMonth() + " " + String.valueOf(std.getDayOfMonth())
+ ", " + String.valueOf(std.getYear());
return stdFormat;
}
//Formats the Departure date as per the requirement given question
String getDepartureDateFormatted()
8. {
String stdFormat;
stdFormat = "Departure Date: " + end.getMonth() + " " +
String.valueOf(end.getDayOfMonth()) + ", " + String.valueOf(end.getYear());
return stdFormat;
}
//Returns the Price per night as per the format
String getPricePerNightFormatted()
{
String pr = "Price: $" + String.valueOf(perNight) + " per night";
return pr;
}
//Returns the number of nights
long getNumberOfNights()
{
//toEpochDay() returns number of days
noDays = end.toEpochDay() - std.toEpochDay();
return noDays;
}
//Calculates final Amount to be paid
double getTotalPrice()
{
finalAmt = (double)getNumberOfNights() * perNight;
return finalAmt;
}
//Returns the Total amount to be paid as per the format given in the question
String getTotalPriceFormatted()
{
String finA = "Total price: $" + String.valueOf(getTotalPrice()) + " for " +
String.valueOf(getNumberOfNights()) + " night" ;
return finA;
}
9. //Accepts the Arrival date and Departure date from console
void accept()
{
//Creates object of LocaleDate
LocalDate std1, end1;
//Creates the Date Time Formater object and applies Format Style
//SHORT in mm/dd/yy format
DateTimeFormatter fmt = DateTimeFormatter.ofLocalizedDate(FormatStyle.SHORT);
//Creates Scanner class object to accept data from console
Scanner s = new Scanner(System.in);
System.out.println("Enter starting date mm/dd/yyyy: ");
System.out.println("Enter the arrival month (1-12):");
m = s.nextInt(); //Accept data in integer format
System.out.println("Enter the arrival day (1-31):") ;
d = s.nextInt();
System.out.println("Enter the arrival year:") ;
y = s.nextInt();
//Initializes the LocalDate object for Arrival date
std1 = LocalDate.of(y, m, d);
//Sets the SHORT date format
fmt.format(std1);
//Assigns Arrival date to class data member
setArrivalDate(std1);
System.out.println("Enter ending date mm/dd/yyyy: ");
System.out.println("Enter the departure month (1-12):");
m = s.nextInt(); //Accept data in integer format
System.out.println("Enter the departure day (1-31):") ;
d = s.nextInt();
10. System.out.println("Enter the departure year:") ;
y = s.nextInt();
//Initializes the LocalDate object for Departure date
end1 = LocalDate.of(y, m, d);
//Sets the SHORT date format
fmt.format(std1);
//Assigns Departure date to class data member
setDepartureDate(end1);
}
public static void main(String[] args)
{
char ch;
System.out.println("Welcome to the Reservation Calculator ");
//Creates Reservation class object
Reservation cc = new Reservation();
Scanner s = new Scanner(System.in);
//Loops till Y is pressed
do
{
cc.accept();
System.out.println(cc.getArrivalDateFormatted());
System.out.println(cc.getDepartureDateFormatted());
System.out.println(cc.getPricePerNightFormatted());
System.out.println(cc.getTotalPriceFormatted());
System.out.println("Would you like to continue? (y/n)");
ch = s.next().charAt(0);
if(ch == 'y' || ch == 'Y')
continue;
else
break;
}while(true);
11. }
}
Output
Welcome to the Reservation Calculator
Enter starting date mm/dd/yyyy:
Enter the arrival month (1-12):
5
Enter the arrival day (1-31):
16
Enter the arrival year:
2016
Enter ending date mm/dd/yyyy:
Enter the departure month (1-12):
5
Enter the departure day (1-31):
18
Enter the departure year:
2016
Arrival Date: MAY 16, 2016
Departure Date: MAY 18, 2016
Price: $105.0 per night
Total price: $210.0 for 2 night
Would you like to continue? (y/n)
y
Enter starting date mm/dd/yyyy:
Enter the arrival month (1-12):
7
Enter the arrival day (1-31):
20
Enter the arrival year:
2016
Enter ending date mm/dd/yyyy:
Enter the departure month (1-12):
7
Enter the departure day (1-31):
27
12. Enter the departure year:
2016
Arrival Date: JULY 20, 2016
Departure Date: JULY 27, 2016
Price: $105.0 per night
Total price: $735.0 for 7 night
Would you like to continue? (y/n)
n