SlideShare a Scribd company logo
1 of 4
Download to read offline
Program:
import java.util.*;
import java.io.*;
class FoodTruck
{
String truckName;
double fuelintruck;
int numberofemplyees;
String menuItems[]=new String[5];
public void getData()
{
Scanner s=new Scanner(System.in);
System.out.print("Enter TruckName");
truckName=s.next();
System.out.print("Enter Fuel in Tank ");
fuelintruck=s.nextDouble();
System.out.print("Enter number of employess in truck");
numberofemplyees=s.nextInt();
System.out.print("Enter Menu Items");
for(int i=0;i<5;i++)
menuItems[i]=s.next();
}
public void ckeckfuel()
{
if(fuelintruck<2.5)
System.out.println("Please refill your truck");
else
System.out.println("Fuel is enough");
}
public void displayMenu()
{
try
{
FileOutputStream fout=new FileOutputStream("Menu.txt");
for(int i=0;i<5;i++)
{
byte b[]=menuItems[i].getBytes();
fout.write(b);
System.out.println(menuItems[i]);
}
}
catch(IOException e)
{
System.out.println(e.getMessage());
}
}
}
public class MyTruck1
{
public static void main(String ar[])
{
FoodTruck ft=new FoodTruck();
ft.getData();
ft.ckeckfuel();
ft.displayMenu();
}
}
Output:
Enter TruckNameFoodpanda
Enter Fuel in Tank 25.4
Enter number of employess in truck5
Enter Menu Itemssabji dal papad noodels paneer
Fuel is enough
sabji
dal
papad
noodels
paneer
Solution
Program:
import java.util.*;
import java.io.*;
class FoodTruck
{
String truckName;
double fuelintruck;
int numberofemplyees;
String menuItems[]=new String[5];
public void getData()
{
Scanner s=new Scanner(System.in);
System.out.print("Enter TruckName");
truckName=s.next();
System.out.print("Enter Fuel in Tank ");
fuelintruck=s.nextDouble();
System.out.print("Enter number of employess in truck");
numberofemplyees=s.nextInt();
System.out.print("Enter Menu Items");
for(int i=0;i<5;i++)
menuItems[i]=s.next();
}
public void ckeckfuel()
{
if(fuelintruck<2.5)
System.out.println("Please refill your truck");
else
System.out.println("Fuel is enough");
}
public void displayMenu()
{
try
{
FileOutputStream fout=new FileOutputStream("Menu.txt");
for(int i=0;i<5;i++)
{
byte b[]=menuItems[i].getBytes();
fout.write(b);
System.out.println(menuItems[i]);
}
}
catch(IOException e)
{
System.out.println(e.getMessage());
}
}
}
public class MyTruck1
{
public static void main(String ar[])
{
FoodTruck ft=new FoodTruck();
ft.getData();
ft.ckeckfuel();
ft.displayMenu();
}
}
Output:
Enter TruckNameFoodpanda
Enter Fuel in Tank 25.4
Enter number of employess in truck5
Enter Menu Itemssabji dal papad noodels paneer
Fuel is enough
sabji
dal
papad
noodels
paneer

More Related Content

Similar to Programimport java.util.; import java.io.; class FoodTruck.pdf

In this assignment you will practice creating classes and enumeratio.pdf
In this assignment you will practice creating classes and enumeratio.pdfIn this assignment you will practice creating classes and enumeratio.pdf
In this assignment you will practice creating classes and enumeratio.pdf
ivylinvaydak64229
 
3. Section 3 � Complete functionality on listing screen (1.5 marks.pdf
3. Section 3 � Complete functionality on listing screen (1.5 marks.pdf3. Section 3 � Complete functionality on listing screen (1.5 marks.pdf
3. Section 3 � Complete functionality on listing screen (1.5 marks.pdf
alliedscorporation
 
the code below is a recommendation system application to suggest a s.pdf
the code below is a recommendation system application to suggest a s.pdfthe code below is a recommendation system application to suggest a s.pdf
the code below is a recommendation system application to suggest a s.pdf
rajatchugh13
 
Vehicle.javapublic class Vehicle {    Declaring instance var.pdf
Vehicle.javapublic class Vehicle {    Declaring instance var.pdfVehicle.javapublic class Vehicle {    Declaring instance var.pdf
Vehicle.javapublic class Vehicle {    Declaring instance var.pdf
anujsharmaanuj14
 
You are to simulate a dispatcher using a priority queue system in C+.pdf
You are to simulate a dispatcher using a priority queue system in C+.pdfYou are to simulate a dispatcher using a priority queue system in C+.pdf
You are to simulate a dispatcher using a priority queue system in C+.pdf
JUSTSTYLISH3B2MOHALI
 
Software Engineer Screening Question - OOP
Software Engineer Screening Question - OOPSoftware Engineer Screening Question - OOP
Software Engineer Screening Question - OOP
jason_scorebig
 
I need to do the followingAdd a new item to the inventory m.pdf
I need to do the followingAdd a new item to the inventory m.pdfI need to do the followingAdd a new item to the inventory m.pdf
I need to do the followingAdd a new item to the inventory m.pdf
adianantsolutions
 
Create a menu-driven program that will accept a collection of non-ne.pdf
Create a menu-driven program that will accept a collection of non-ne.pdfCreate a menu-driven program that will accept a collection of non-ne.pdf
Create a menu-driven program that will accept a collection of non-ne.pdf
rajeshjangid1865
 
Driverimport java.util.Scanner;A class that keeps a f.pdf
Driverimport java.util.Scanner;A class that keeps a f.pdfDriverimport java.util.Scanner;A class that keeps a f.pdf
Driverimport java.util.Scanner;A class that keeps a f.pdf
arihantstoneart
 
Java programI made this Account.java below. Using the attached cod.pdf
Java programI made this Account.java below. Using the attached cod.pdfJava programI made this Account.java below. Using the attached cod.pdf
Java programI made this Account.java below. Using the attached cod.pdf
fathimafancy
 

Similar to Programimport java.util.; import java.io.; class FoodTruck.pdf (19)

OOP program questions with answers
OOP program questions with answersOOP program questions with answers
OOP program questions with answers
 
Java doc Pr ITM2
Java doc Pr ITM2Java doc Pr ITM2
Java doc Pr ITM2
 
In this assignment you will practice creating classes and enumeratio.pdf
In this assignment you will practice creating classes and enumeratio.pdfIn this assignment you will practice creating classes and enumeratio.pdf
In this assignment you will practice creating classes and enumeratio.pdf
 
Creating a Facebook Clone - Part XLVI - Transcript.pdf
Creating a Facebook Clone - Part XLVI - Transcript.pdfCreating a Facebook Clone - Part XLVI - Transcript.pdf
Creating a Facebook Clone - Part XLVI - Transcript.pdf
 
3. Section 3 � Complete functionality on listing screen (1.5 marks.pdf
3. Section 3 � Complete functionality on listing screen (1.5 marks.pdf3. Section 3 � Complete functionality on listing screen (1.5 marks.pdf
3. Section 3 � Complete functionality on listing screen (1.5 marks.pdf
 
the code below is a recommendation system application to suggest a s.pdf
the code below is a recommendation system application to suggest a s.pdfthe code below is a recommendation system application to suggest a s.pdf
the code below is a recommendation system application to suggest a s.pdf
 
Vehicle.javapublic class Vehicle {    Declaring instance var.pdf
Vehicle.javapublic class Vehicle {    Declaring instance var.pdfVehicle.javapublic class Vehicle {    Declaring instance var.pdf
Vehicle.javapublic class Vehicle {    Declaring instance var.pdf
 
You are to simulate a dispatcher using a priority queue system in C+.pdf
You are to simulate a dispatcher using a priority queue system in C+.pdfYou are to simulate a dispatcher using a priority queue system in C+.pdf
You are to simulate a dispatcher using a priority queue system in C+.pdf
 
Java Programs
Java ProgramsJava Programs
Java Programs
 
Software Engineer Screening Question - OOP
Software Engineer Screening Question - OOPSoftware Engineer Screening Question - OOP
Software Engineer Screening Question - OOP
 
Lab101.pptx
Lab101.pptxLab101.pptx
Lab101.pptx
 
2. Create a Java class called EmployeeMain within the same project Pr.docx
 2. Create a Java class called EmployeeMain within the same project Pr.docx 2. Create a Java class called EmployeeMain within the same project Pr.docx
2. Create a Java class called EmployeeMain within the same project Pr.docx
 
I need to do the followingAdd a new item to the inventory m.pdf
I need to do the followingAdd a new item to the inventory m.pdfI need to do the followingAdd a new item to the inventory m.pdf
I need to do the followingAdd a new item to the inventory m.pdf
 
Create a menu-driven program that will accept a collection of non-ne.pdf
Create a menu-driven program that will accept a collection of non-ne.pdfCreate a menu-driven program that will accept a collection of non-ne.pdf
Create a menu-driven program that will accept a collection of non-ne.pdf
 
programming for Calculator in java
programming for Calculator in javaprogramming for Calculator in java
programming for Calculator in java
 
Driverimport java.util.Scanner;A class that keeps a f.pdf
Driverimport java.util.Scanner;A class that keeps a f.pdfDriverimport java.util.Scanner;A class that keeps a f.pdf
Driverimport java.util.Scanner;A class that keeps a f.pdf
 
Java programI made this Account.java below. Using the attached cod.pdf
Java programI made this Account.java below. Using the attached cod.pdfJava programI made this Account.java below. Using the attached cod.pdf
Java programI made this Account.java below. Using the attached cod.pdf
 
Java calculator
Java calculatorJava calculator
Java calculator
 
Java programs
Java programsJava programs
Java programs
 

More from apleathers

While a majority of the worlds current electricity supply is gener.pdf
While a majority of the worlds current electricity supply is gener.pdfWhile a majority of the worlds current electricity supply is gener.pdf
While a majority of the worlds current electricity supply is gener.pdf
apleathers
 
What is broadbandWhat is the potential for broadband wireless syste.pdf
What is broadbandWhat is the potential for broadband wireless syste.pdfWhat is broadbandWhat is the potential for broadband wireless syste.pdf
What is broadbandWhat is the potential for broadband wireless syste.pdf
apleathers
 
Thousands of repeating units called nephrons will form a kidney and .pdf
Thousands of repeating units called nephrons will form a kidney and .pdfThousands of repeating units called nephrons will form a kidney and .pdf
Thousands of repeating units called nephrons will form a kidney and .pdf
apleathers
 
To understand the complexicities of the issue at hand we must first .pdf
To understand the complexicities of the issue at hand we must first .pdfTo understand the complexicities of the issue at hand we must first .pdf
To understand the complexicities of the issue at hand we must first .pdf
apleathers
 
Ques-1 Prenatal diagnosis has both positive and potentially negativ.pdf
Ques-1 Prenatal diagnosis has both positive and potentially negativ.pdfQues-1 Prenatal diagnosis has both positive and potentially negativ.pdf
Ques-1 Prenatal diagnosis has both positive and potentially negativ.pdf
apleathers
 
QuestionWhat are the elements of safe drinking water act What ar.pdf
QuestionWhat are the elements of safe drinking water act What ar.pdfQuestionWhat are the elements of safe drinking water act What ar.pdf
QuestionWhat are the elements of safe drinking water act What ar.pdf
apleathers
 
Please follow the data and description Active Directory In gen.pdf
Please follow the data and description Active Directory In gen.pdfPlease follow the data and description Active Directory In gen.pdf
Please follow the data and description Active Directory In gen.pdf
apleathers
 
package DataStructures; public class HelloWorld AnyType extends.pdf
package DataStructures; public class HelloWorld AnyType extends.pdfpackage DataStructures; public class HelloWorld AnyType extends.pdf
package DataStructures; public class HelloWorld AnyType extends.pdf
apleathers
 
import java.util.Scanner;public class Fraction {   instan.pdf
import java.util.Scanner;public class Fraction {    instan.pdfimport java.util.Scanner;public class Fraction {    instan.pdf
import java.util.Scanner;public class Fraction {   instan.pdf
apleathers
 
Hi,Please find the Ansswer below.PLAYLIST.h#include iostrea.pdf
Hi,Please find the Ansswer below.PLAYLIST.h#include iostrea.pdfHi,Please find the Ansswer below.PLAYLIST.h#include iostrea.pdf
Hi,Please find the Ansswer below.PLAYLIST.h#include iostrea.pdf
apleathers
 
Family as a Social Institution A family can be defined as group of .pdf
Family as a Social Institution A family can be defined as group of .pdfFamily as a Social Institution A family can be defined as group of .pdf
Family as a Social Institution A family can be defined as group of .pdf
apleathers
 

More from apleathers (20)

While a majority of the worlds current electricity supply is gener.pdf
While a majority of the worlds current electricity supply is gener.pdfWhile a majority of the worlds current electricity supply is gener.pdf
While a majority of the worlds current electricity supply is gener.pdf
 
What is broadbandWhat is the potential for broadband wireless syste.pdf
What is broadbandWhat is the potential for broadband wireless syste.pdfWhat is broadbandWhat is the potential for broadband wireless syste.pdf
What is broadbandWhat is the potential for broadband wireless syste.pdf
 
WaterSolutionWater.pdf
WaterSolutionWater.pdfWaterSolutionWater.pdf
WaterSolutionWater.pdf
 
Thousands of repeating units called nephrons will form a kidney and .pdf
Thousands of repeating units called nephrons will form a kidney and .pdfThousands of repeating units called nephrons will form a kidney and .pdf
Thousands of repeating units called nephrons will form a kidney and .pdf
 
To understand the complexicities of the issue at hand we must first .pdf
To understand the complexicities of the issue at hand we must first .pdfTo understand the complexicities of the issue at hand we must first .pdf
To understand the complexicities of the issue at hand we must first .pdf
 
The P is the present value of the cash flow streamP = 100 (1+10.pdf
The P is the present value of the cash flow streamP = 100  (1+10.pdfThe P is the present value of the cash flow streamP = 100  (1+10.pdf
The P is the present value of the cash flow streamP = 100 (1+10.pdf
 
Ribose sugar puckers adopt for both Deoxy nucleotides and ribonucleo.pdf
Ribose sugar puckers adopt for both Deoxy nucleotides and ribonucleo.pdfRibose sugar puckers adopt for both Deoxy nucleotides and ribonucleo.pdf
Ribose sugar puckers adopt for both Deoxy nucleotides and ribonucleo.pdf
 
Ques-1 Prenatal diagnosis has both positive and potentially negativ.pdf
Ques-1 Prenatal diagnosis has both positive and potentially negativ.pdfQues-1 Prenatal diagnosis has both positive and potentially negativ.pdf
Ques-1 Prenatal diagnosis has both positive and potentially negativ.pdf
 
QuestionWhat are the elements of safe drinking water act What ar.pdf
QuestionWhat are the elements of safe drinking water act What ar.pdfQuestionWhat are the elements of safe drinking water act What ar.pdf
QuestionWhat are the elements of safe drinking water act What ar.pdf
 
Please follow the data and description Active Directory In gen.pdf
Please follow the data and description Active Directory In gen.pdfPlease follow the data and description Active Directory In gen.pdf
Please follow the data and description Active Directory In gen.pdf
 
package DataStructures; public class HelloWorld AnyType extends.pdf
package DataStructures; public class HelloWorld AnyType extends.pdfpackage DataStructures; public class HelloWorld AnyType extends.pdf
package DataStructures; public class HelloWorld AnyType extends.pdf
 
it always attacks oxygen.the image doesnot workSolutionit alwa.pdf
it always attacks oxygen.the image doesnot workSolutionit alwa.pdfit always attacks oxygen.the image doesnot workSolutionit alwa.pdf
it always attacks oxygen.the image doesnot workSolutionit alwa.pdf
 
import java.util.Scanner;public class Fraction {   instan.pdf
import java.util.Scanner;public class Fraction {    instan.pdfimport java.util.Scanner;public class Fraction {    instan.pdf
import java.util.Scanner;public class Fraction {   instan.pdf
 
Hi,Please find the Ansswer below.PLAYLIST.h#include iostrea.pdf
Hi,Please find the Ansswer below.PLAYLIST.h#include iostrea.pdfHi,Please find the Ansswer below.PLAYLIST.h#include iostrea.pdf
Hi,Please find the Ansswer below.PLAYLIST.h#include iostrea.pdf
 
Family as a Social Institution A family can be defined as group of .pdf
Family as a Social Institution A family can be defined as group of .pdfFamily as a Social Institution A family can be defined as group of .pdf
Family as a Social Institution A family can be defined as group of .pdf
 
D. The actual development of new standards and protocols for the Int.pdf
D. The actual development of new standards and protocols for the Int.pdfD. The actual development of new standards and protocols for the Int.pdf
D. The actual development of new standards and protocols for the Int.pdf
 
Dependent Variable. A variable that depends on one or more other var.pdf
Dependent Variable. A variable that depends on one or more other var.pdfDependent Variable. A variable that depends on one or more other var.pdf
Dependent Variable. A variable that depends on one or more other var.pdf
 
C is correct. While all Layer 2 devices split collision domains, swi.pdf
C is correct. While all Layer 2 devices split collision domains, swi.pdfC is correct. While all Layer 2 devices split collision domains, swi.pdf
C is correct. While all Layer 2 devices split collision domains, swi.pdf
 
Answer.The following organisms are present in pod.1. Prokaryotes.pdf
Answer.The following organisms are present in pod.1. Prokaryotes.pdfAnswer.The following organisms are present in pod.1. Prokaryotes.pdf
Answer.The following organisms are present in pod.1. Prokaryotes.pdf
 
AnswerThe mobile elements are the elerments move form one place t.pdf
AnswerThe mobile elements are the elerments move form one place t.pdfAnswerThe mobile elements are the elerments move form one place t.pdf
AnswerThe mobile elements are the elerments move form one place t.pdf
 

Recently uploaded

Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
EADTU
 
SURVEY I created for uni project research
SURVEY I created for uni project researchSURVEY I created for uni project research
SURVEY I created for uni project research
CaitlinCummins3
 

Recently uploaded (20)

Mattingly "AI and Prompt Design: LLMs with NER"
Mattingly "AI and Prompt Design: LLMs with NER"Mattingly "AI and Prompt Design: LLMs with NER"
Mattingly "AI and Prompt Design: LLMs with NER"
 
The Story of Village Palampur Class 9 Free Study Material PDF
The Story of Village Palampur Class 9 Free Study Material PDFThe Story of Village Palampur Class 9 Free Study Material PDF
The Story of Village Palampur Class 9 Free Study Material PDF
 
AIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.pptAIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.ppt
 
PSYPACT- Practicing Over State Lines May 2024.pptx
PSYPACT- Practicing Over State Lines May 2024.pptxPSYPACT- Practicing Over State Lines May 2024.pptx
PSYPACT- Practicing Over State Lines May 2024.pptx
 
OS-operating systems- ch05 (CPU Scheduling) ...
OS-operating systems- ch05 (CPU Scheduling) ...OS-operating systems- ch05 (CPU Scheduling) ...
OS-operating systems- ch05 (CPU Scheduling) ...
 
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
 
8 Tips for Effective Working Capital Management
8 Tips for Effective Working Capital Management8 Tips for Effective Working Capital Management
8 Tips for Effective Working Capital Management
 
VAMOS CUIDAR DO NOSSO PLANETA! .
VAMOS CUIDAR DO NOSSO PLANETA!                    .VAMOS CUIDAR DO NOSSO PLANETA!                    .
VAMOS CUIDAR DO NOSSO PLANETA! .
 
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading RoomSternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
 
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
 
How To Create Editable Tree View in Odoo 17
How To Create Editable Tree View in Odoo 17How To Create Editable Tree View in Odoo 17
How To Create Editable Tree View in Odoo 17
 
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
 
male presentation...pdf.................
male presentation...pdf.................male presentation...pdf.................
male presentation...pdf.................
 
diagnosting testing bsc 2nd sem.pptx....
diagnosting testing bsc 2nd sem.pptx....diagnosting testing bsc 2nd sem.pptx....
diagnosting testing bsc 2nd sem.pptx....
 
SURVEY I created for uni project research
SURVEY I created for uni project researchSURVEY I created for uni project research
SURVEY I created for uni project research
 
ANTI PARKISON DRUGS.pptx
ANTI         PARKISON          DRUGS.pptxANTI         PARKISON          DRUGS.pptx
ANTI PARKISON DRUGS.pptx
 
ESSENTIAL of (CS/IT/IS) class 07 (Networks)
ESSENTIAL of (CS/IT/IS) class 07 (Networks)ESSENTIAL of (CS/IT/IS) class 07 (Networks)
ESSENTIAL of (CS/IT/IS) class 07 (Networks)
 
Supporting Newcomer Multilingual Learners
Supporting Newcomer  Multilingual LearnersSupporting Newcomer  Multilingual Learners
Supporting Newcomer Multilingual Learners
 
Major project report on Tata Motors and its marketing strategies
Major project report on Tata Motors and its marketing strategiesMajor project report on Tata Motors and its marketing strategies
Major project report on Tata Motors and its marketing strategies
 
Đề tieng anh thpt 2024 danh cho cac ban hoc sinh
Đề tieng anh thpt 2024 danh cho cac ban hoc sinhĐề tieng anh thpt 2024 danh cho cac ban hoc sinh
Đề tieng anh thpt 2024 danh cho cac ban hoc sinh
 

Programimport java.util.; import java.io.; class FoodTruck.pdf

  • 1. Program: import java.util.*; import java.io.*; class FoodTruck { String truckName; double fuelintruck; int numberofemplyees; String menuItems[]=new String[5]; public void getData() { Scanner s=new Scanner(System.in); System.out.print("Enter TruckName"); truckName=s.next(); System.out.print("Enter Fuel in Tank "); fuelintruck=s.nextDouble(); System.out.print("Enter number of employess in truck"); numberofemplyees=s.nextInt(); System.out.print("Enter Menu Items"); for(int i=0;i<5;i++) menuItems[i]=s.next(); } public void ckeckfuel() { if(fuelintruck<2.5) System.out.println("Please refill your truck"); else System.out.println("Fuel is enough"); } public void displayMenu() { try { FileOutputStream fout=new FileOutputStream("Menu.txt"); for(int i=0;i<5;i++)
  • 2. { byte b[]=menuItems[i].getBytes(); fout.write(b); System.out.println(menuItems[i]); } } catch(IOException e) { System.out.println(e.getMessage()); } } } public class MyTruck1 { public static void main(String ar[]) { FoodTruck ft=new FoodTruck(); ft.getData(); ft.ckeckfuel(); ft.displayMenu(); } } Output: Enter TruckNameFoodpanda Enter Fuel in Tank 25.4 Enter number of employess in truck5 Enter Menu Itemssabji dal papad noodels paneer Fuel is enough sabji dal papad noodels paneer Solution
  • 3. Program: import java.util.*; import java.io.*; class FoodTruck { String truckName; double fuelintruck; int numberofemplyees; String menuItems[]=new String[5]; public void getData() { Scanner s=new Scanner(System.in); System.out.print("Enter TruckName"); truckName=s.next(); System.out.print("Enter Fuel in Tank "); fuelintruck=s.nextDouble(); System.out.print("Enter number of employess in truck"); numberofemplyees=s.nextInt(); System.out.print("Enter Menu Items"); for(int i=0;i<5;i++) menuItems[i]=s.next(); } public void ckeckfuel() { if(fuelintruck<2.5) System.out.println("Please refill your truck"); else System.out.println("Fuel is enough"); } public void displayMenu() { try { FileOutputStream fout=new FileOutputStream("Menu.txt"); for(int i=0;i<5;i++) {
  • 4. byte b[]=menuItems[i].getBytes(); fout.write(b); System.out.println(menuItems[i]); } } catch(IOException e) { System.out.println(e.getMessage()); } } } public class MyTruck1 { public static void main(String ar[]) { FoodTruck ft=new FoodTruck(); ft.getData(); ft.ckeckfuel(); ft.displayMenu(); } } Output: Enter TruckNameFoodpanda Enter Fuel in Tank 25.4 Enter number of employess in truck5 Enter Menu Itemssabji dal papad noodels paneer Fuel is enough sabji dal papad noodels paneer