SlideShare a Scribd company logo
Create a document with a form that registers all non-profit organizations in the area, the number
of members they have, and the type of organization. After the user enters data in all the fields
and presses the button, your program will create a single text le that saves information for each
organization on a separate line. The name of the data file is np.txt. This data file should be
created in the same directory as your running program, without hard-coding the file path to
ensure portability.
In the data file please include the Organization name, Membership, and Type, separated by
commas. Membership should only accept numbers, Type should only accept the following
strings: Educational, Animal Rescue, Religious, Food Service, and misspellings should not be
allowed. The first line of the output will be the headers. You can make up all the names and
numbers while you are testing your programs.
Sample Output written to a file will look as following:
Organization, Membership, Type
Meals on Trucks, 123, Food Service
The Church of Purple Cross, 34, Religious
Kitties and Puppies, 1234, Animal Rescue
Solution
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Scanner;
public class WriteToFile {
private static final String FILENAME = "np.txt.";
private static Scanner s;
static int mem;
static String org, type;
static int getMem() {
System.out.println("Enter Membership Number: ");
return s.nextInt();
}
public static void main(String[] args) {
try (BufferedWriter bw = new BufferedWriter(new FileWriter(FILENAME))) {
boolean isMore = true;
s = new Scanner(System.in);
String content = "Organization, Membership, Type";
bw.write(content);
while (isMore) {
System.out.println("Enter Organization Name: ");
org = s.nextLine();
try {
System.out.println("Enter Membership Number: ");
mem = s.nextInt();
} catch (Exception e) {
System.out.println("Membership Should only be of Number Type");
mem = getMem();
}
boolean end = false;
do {
System.out.println("Enter Type Of Organization: ");
type = s.next();
switch (type) {
case "Educational":
break;
case "Animal Rescue":
break;
case "Religious":
break;
case "Food Service":
break;
default:
{
System.out.println(
"Type Name Should be Only Educational, Animal Rescue ,Religious ,Food
Service");
end = true;
}
}
} while (end);
String f=org+","+mem+","+type;
bw.newLine();
bw.append(f);
System.out.println("Enter More Enteries?(y/n) :");
if(s.next().equals("n"))
isMore=false;
}
} catch (IOException e) {
e.printStackTrace();
}
}
}

More Related Content

Similar to Create a document with a form that registers all non-profit organiza.pdf

python file handling
python file handlingpython file handling
python file handling
jhona2z
 
There are many different tools available to forensic investigato.docx
There are many different tools available to forensic investigato.docxThere are many different tools available to forensic investigato.docx
There are many different tools available to forensic investigato.docx
croftsshanon
 
Change the code in Writer.java only to get it working. Must contain .pdf
Change the code in Writer.java only to get it working. Must contain .pdfChange the code in Writer.java only to get it working. Must contain .pdf
Change the code in Writer.java only to get it working. Must contain .pdf
secunderbadtirumalgi
 
Registry forensics
Registry forensicsRegistry forensics
Registry forensics
Prince Boonlia
 
D2L Site Admin Tools Discussion at Brightspace South Carolina Connection
D2L Site Admin Tools Discussion at Brightspace South Carolina ConnectionD2L Site Admin Tools Discussion at Brightspace South Carolina Connection
D2L Site Admin Tools Discussion at Brightspace South Carolina Connection
D2L Barry
 
Xpsupport
XpsupportXpsupport
Xpsupport
Adil Jafri
 
Austin Powell - Digital Forensic Case Study.pdf
Austin Powell - Digital Forensic Case Study.pdfAustin Powell - Digital Forensic Case Study.pdf
Austin Powell - Digital Forensic Case Study.pdf
AustinDeanPowell
 
Need help with this java code. fill in lines where needed. Also, not.pdf
Need help with this java code. fill in lines where needed. Also, not.pdfNeed help with this java code. fill in lines where needed. Also, not.pdf
Need help with this java code. fill in lines where needed. Also, not.pdf
rishabjain5053
 
Write a C++ program that reads in a list of first and last names fro.pdf
Write a C++ program that reads in a list of first and last names fro.pdfWrite a C++ program that reads in a list of first and last names fro.pdf
Write a C++ program that reads in a list of first and last names fro.pdf
ramasamyarm
 
PAGE 1Input output for a file tutorialStreams and File IOI.docx
PAGE  1Input output for a file tutorialStreams and File IOI.docxPAGE  1Input output for a file tutorialStreams and File IOI.docx
PAGE 1Input output for a file tutorialStreams and File IOI.docx
alfred4lewis58146
 
Write a program in java that asks a user for a file name and prints .pdf
Write a program in java that asks a user for a file name and prints .pdfWrite a program in java that asks a user for a file name and prints .pdf
Write a program in java that asks a user for a file name and prints .pdf
atulkapoor33
 
Chapter 10.1
Chapter 10.1Chapter 10.1
Chapter 10.1
sotlsoc
 
Apache tika
Apache tikaApache tika
Eventlog
EventlogEventlog
Eventlog
Shashi Kanth
 
File Handling In C++(OOPs))
File Handling In C++(OOPs))File Handling In C++(OOPs))
File Handling In C++(OOPs))
Papu Kumar
 
Copyright © 2018 Pearson Education, Inc. C H A P T E R 6.docx
Copyright © 2018 Pearson Education, Inc. C H A P T E R  6.docxCopyright © 2018 Pearson Education, Inc. C H A P T E R  6.docx
Copyright © 2018 Pearson Education, Inc. C H A P T E R 6.docx
dickonsondorris
 
Create a text file named lnfo.txt. Enter the following informatio.pdf
Create a text file named lnfo.txt. Enter the following informatio.pdfCreate a text file named lnfo.txt. Enter the following informatio.pdf
Create a text file named lnfo.txt. Enter the following informatio.pdf
shahidqamar17
 
File Handling in Java.pdf
File Handling in Java.pdfFile Handling in Java.pdf
File Handling in Java.pdf
SudhanshiBakre1
 
Assignment #4 will be the construction of 2 new classes and a driver program/...
Assignment #4 will be the construction of 2 new classes and a driver program/...Assignment #4 will be the construction of 2 new classes and a driver program/...
Assignment #4 will be the construction of 2 new classes and a driver program/...
hwbloom3
 
File Handling In C++
File Handling In C++File Handling In C++

Similar to Create a document with a form that registers all non-profit organiza.pdf (20)

python file handling
python file handlingpython file handling
python file handling
 
There are many different tools available to forensic investigato.docx
There are many different tools available to forensic investigato.docxThere are many different tools available to forensic investigato.docx
There are many different tools available to forensic investigato.docx
 
Change the code in Writer.java only to get it working. Must contain .pdf
Change the code in Writer.java only to get it working. Must contain .pdfChange the code in Writer.java only to get it working. Must contain .pdf
Change the code in Writer.java only to get it working. Must contain .pdf
 
Registry forensics
Registry forensicsRegistry forensics
Registry forensics
 
D2L Site Admin Tools Discussion at Brightspace South Carolina Connection
D2L Site Admin Tools Discussion at Brightspace South Carolina ConnectionD2L Site Admin Tools Discussion at Brightspace South Carolina Connection
D2L Site Admin Tools Discussion at Brightspace South Carolina Connection
 
Xpsupport
XpsupportXpsupport
Xpsupport
 
Austin Powell - Digital Forensic Case Study.pdf
Austin Powell - Digital Forensic Case Study.pdfAustin Powell - Digital Forensic Case Study.pdf
Austin Powell - Digital Forensic Case Study.pdf
 
Need help with this java code. fill in lines where needed. Also, not.pdf
Need help with this java code. fill in lines where needed. Also, not.pdfNeed help with this java code. fill in lines where needed. Also, not.pdf
Need help with this java code. fill in lines where needed. Also, not.pdf
 
Write a C++ program that reads in a list of first and last names fro.pdf
Write a C++ program that reads in a list of first and last names fro.pdfWrite a C++ program that reads in a list of first and last names fro.pdf
Write a C++ program that reads in a list of first and last names fro.pdf
 
PAGE 1Input output for a file tutorialStreams and File IOI.docx
PAGE  1Input output for a file tutorialStreams and File IOI.docxPAGE  1Input output for a file tutorialStreams and File IOI.docx
PAGE 1Input output for a file tutorialStreams and File IOI.docx
 
Write a program in java that asks a user for a file name and prints .pdf
Write a program in java that asks a user for a file name and prints .pdfWrite a program in java that asks a user for a file name and prints .pdf
Write a program in java that asks a user for a file name and prints .pdf
 
Chapter 10.1
Chapter 10.1Chapter 10.1
Chapter 10.1
 
Apache tika
Apache tikaApache tika
Apache tika
 
Eventlog
EventlogEventlog
Eventlog
 
File Handling In C++(OOPs))
File Handling In C++(OOPs))File Handling In C++(OOPs))
File Handling In C++(OOPs))
 
Copyright © 2018 Pearson Education, Inc. C H A P T E R 6.docx
Copyright © 2018 Pearson Education, Inc. C H A P T E R  6.docxCopyright © 2018 Pearson Education, Inc. C H A P T E R  6.docx
Copyright © 2018 Pearson Education, Inc. C H A P T E R 6.docx
 
Create a text file named lnfo.txt. Enter the following informatio.pdf
Create a text file named lnfo.txt. Enter the following informatio.pdfCreate a text file named lnfo.txt. Enter the following informatio.pdf
Create a text file named lnfo.txt. Enter the following informatio.pdf
 
File Handling in Java.pdf
File Handling in Java.pdfFile Handling in Java.pdf
File Handling in Java.pdf
 
Assignment #4 will be the construction of 2 new classes and a driver program/...
Assignment #4 will be the construction of 2 new classes and a driver program/...Assignment #4 will be the construction of 2 new classes and a driver program/...
Assignment #4 will be the construction of 2 new classes and a driver program/...
 
File Handling In C++
File Handling In C++File Handling In C++
File Handling In C++
 

More from rohit219406

Below are the transactions and adjustments that occurred during the .pdf
Below are the transactions and adjustments that occurred during the .pdfBelow are the transactions and adjustments that occurred during the .pdf
Below are the transactions and adjustments that occurred during the .pdf
rohit219406
 
Help Please. Results not given Explain how your results for the pe.pdf
Help Please. Results not given Explain how your results for the pe.pdfHelp Please. Results not given Explain how your results for the pe.pdf
Help Please. Results not given Explain how your results for the pe.pdf
rohit219406
 
As a software developer you have been delegated with the assignment .pdf
As a software developer you have been delegated with the assignment .pdfAs a software developer you have been delegated with the assignment .pdf
As a software developer you have been delegated with the assignment .pdf
rohit219406
 
What scientist is credited with proposing the equivalency of mass and.pdf
What scientist is credited with proposing the equivalency of mass and.pdfWhat scientist is credited with proposing the equivalency of mass and.pdf
What scientist is credited with proposing the equivalency of mass and.pdf
rohit219406
 
Why do countries with high GNI and GDP are attractive for foreign in.pdf
Why do countries with high GNI and GDP are attractive for foreign in.pdfWhy do countries with high GNI and GDP are attractive for foreign in.pdf
Why do countries with high GNI and GDP are attractive for foreign in.pdf
rohit219406
 
Which of the following is NOT true about the ESCBA.It acts as an.pdf
Which of the following is NOT true about the ESCBA.It acts as an.pdfWhich of the following is NOT true about the ESCBA.It acts as an.pdf
Which of the following is NOT true about the ESCBA.It acts as an.pdf
rohit219406
 
What is 4 -4 + infinity - infinity As x approaches 3 from th.pdf
What is  4  -4  + infinity  - infinity  As x approaches 3 from th.pdfWhat is  4  -4  + infinity  - infinity  As x approaches 3 from th.pdf
What is 4 -4 + infinity - infinity As x approaches 3 from th.pdf
rohit219406
 
Use what you have learned so far to bring variety in your writing. U.pdf
Use what you have learned so far to bring variety in your writing. U.pdfUse what you have learned so far to bring variety in your writing. U.pdf
Use what you have learned so far to bring variety in your writing. U.pdf
rohit219406
 
Use C programmingMake sure everything works only uploadSol.pdf
Use C programmingMake sure everything works only uploadSol.pdfUse C programmingMake sure everything works only uploadSol.pdf
Use C programmingMake sure everything works only uploadSol.pdf
rohit219406
 
Thoroughly describe the molecular underpinnings of ONE and only one.pdf
Thoroughly describe the molecular underpinnings of ONE and only one.pdfThoroughly describe the molecular underpinnings of ONE and only one.pdf
Thoroughly describe the molecular underpinnings of ONE and only one.pdf
rohit219406
 
The Blackbeard Company Ltd provided the following information in reg.pdf
The Blackbeard Company Ltd provided the following information in reg.pdfThe Blackbeard Company Ltd provided the following information in reg.pdf
The Blackbeard Company Ltd provided the following information in reg.pdf
rohit219406
 
Thank you 1. What is responsible for anteriorposterior axis formati.pdf
Thank you 1. What is responsible for anteriorposterior axis formati.pdfThank you 1. What is responsible for anteriorposterior axis formati.pdf
Thank you 1. What is responsible for anteriorposterior axis formati.pdf
rohit219406
 
Take the basic Hardy-Weinberg Equilibrium equation, where there are a.pdf
Take the basic Hardy-Weinberg Equilibrium equation, where there are a.pdfTake the basic Hardy-Weinberg Equilibrium equation, where there are a.pdf
Take the basic Hardy-Weinberg Equilibrium equation, where there are a.pdf
rohit219406
 
Systems analysis project 10 can you answer the 4 questions at the t.pdf
Systems analysis project 10 can you answer the 4 questions at the t.pdfSystems analysis project 10 can you answer the 4 questions at the t.pdf
Systems analysis project 10 can you answer the 4 questions at the t.pdf
rohit219406
 
Step 1. Read critically and analyze the following scenarioGeraldi.pdf
Step 1. Read critically and analyze the following scenarioGeraldi.pdfStep 1. Read critically and analyze the following scenarioGeraldi.pdf
Step 1. Read critically and analyze the following scenarioGeraldi.pdf
rohit219406
 
Question 3 2 pts In response to the Great Recession, the Federal Rese.pdf
Question 3 2 pts In response to the Great Recession, the Federal Rese.pdfQuestion 3 2 pts In response to the Great Recession, the Federal Rese.pdf
Question 3 2 pts In response to the Great Recession, the Federal Rese.pdf
rohit219406
 
Prove that the T_i -property is a topological property for i = 0S.pdf
Prove that the T_i -property is a topological property for i = 0S.pdfProve that the T_i -property is a topological property for i = 0S.pdf
Prove that the T_i -property is a topological property for i = 0S.pdf
rohit219406
 
Q4.14. Which of the following species is most likely to exhibit pate.pdf
Q4.14. Which of the following species is most likely to exhibit pate.pdfQ4.14. Which of the following species is most likely to exhibit pate.pdf
Q4.14. Which of the following species is most likely to exhibit pate.pdf
rohit219406
 
Prepare a classified balance sheet. Do not show the components that .pdf
Prepare a classified balance sheet. Do not show the components that .pdfPrepare a classified balance sheet. Do not show the components that .pdf
Prepare a classified balance sheet. Do not show the components that .pdf
rohit219406
 
Microscopes and telescopes both consist of two converging lenses cont.pdf
Microscopes and telescopes both consist of two converging lenses cont.pdfMicroscopes and telescopes both consist of two converging lenses cont.pdf
Microscopes and telescopes both consist of two converging lenses cont.pdf
rohit219406
 

More from rohit219406 (20)

Below are the transactions and adjustments that occurred during the .pdf
Below are the transactions and adjustments that occurred during the .pdfBelow are the transactions and adjustments that occurred during the .pdf
Below are the transactions and adjustments that occurred during the .pdf
 
Help Please. Results not given Explain how your results for the pe.pdf
Help Please. Results not given Explain how your results for the pe.pdfHelp Please. Results not given Explain how your results for the pe.pdf
Help Please. Results not given Explain how your results for the pe.pdf
 
As a software developer you have been delegated with the assignment .pdf
As a software developer you have been delegated with the assignment .pdfAs a software developer you have been delegated with the assignment .pdf
As a software developer you have been delegated with the assignment .pdf
 
What scientist is credited with proposing the equivalency of mass and.pdf
What scientist is credited with proposing the equivalency of mass and.pdfWhat scientist is credited with proposing the equivalency of mass and.pdf
What scientist is credited with proposing the equivalency of mass and.pdf
 
Why do countries with high GNI and GDP are attractive for foreign in.pdf
Why do countries with high GNI and GDP are attractive for foreign in.pdfWhy do countries with high GNI and GDP are attractive for foreign in.pdf
Why do countries with high GNI and GDP are attractive for foreign in.pdf
 
Which of the following is NOT true about the ESCBA.It acts as an.pdf
Which of the following is NOT true about the ESCBA.It acts as an.pdfWhich of the following is NOT true about the ESCBA.It acts as an.pdf
Which of the following is NOT true about the ESCBA.It acts as an.pdf
 
What is 4 -4 + infinity - infinity As x approaches 3 from th.pdf
What is  4  -4  + infinity  - infinity  As x approaches 3 from th.pdfWhat is  4  -4  + infinity  - infinity  As x approaches 3 from th.pdf
What is 4 -4 + infinity - infinity As x approaches 3 from th.pdf
 
Use what you have learned so far to bring variety in your writing. U.pdf
Use what you have learned so far to bring variety in your writing. U.pdfUse what you have learned so far to bring variety in your writing. U.pdf
Use what you have learned so far to bring variety in your writing. U.pdf
 
Use C programmingMake sure everything works only uploadSol.pdf
Use C programmingMake sure everything works only uploadSol.pdfUse C programmingMake sure everything works only uploadSol.pdf
Use C programmingMake sure everything works only uploadSol.pdf
 
Thoroughly describe the molecular underpinnings of ONE and only one.pdf
Thoroughly describe the molecular underpinnings of ONE and only one.pdfThoroughly describe the molecular underpinnings of ONE and only one.pdf
Thoroughly describe the molecular underpinnings of ONE and only one.pdf
 
The Blackbeard Company Ltd provided the following information in reg.pdf
The Blackbeard Company Ltd provided the following information in reg.pdfThe Blackbeard Company Ltd provided the following information in reg.pdf
The Blackbeard Company Ltd provided the following information in reg.pdf
 
Thank you 1. What is responsible for anteriorposterior axis formati.pdf
Thank you 1. What is responsible for anteriorposterior axis formati.pdfThank you 1. What is responsible for anteriorposterior axis formati.pdf
Thank you 1. What is responsible for anteriorposterior axis formati.pdf
 
Take the basic Hardy-Weinberg Equilibrium equation, where there are a.pdf
Take the basic Hardy-Weinberg Equilibrium equation, where there are a.pdfTake the basic Hardy-Weinberg Equilibrium equation, where there are a.pdf
Take the basic Hardy-Weinberg Equilibrium equation, where there are a.pdf
 
Systems analysis project 10 can you answer the 4 questions at the t.pdf
Systems analysis project 10 can you answer the 4 questions at the t.pdfSystems analysis project 10 can you answer the 4 questions at the t.pdf
Systems analysis project 10 can you answer the 4 questions at the t.pdf
 
Step 1. Read critically and analyze the following scenarioGeraldi.pdf
Step 1. Read critically and analyze the following scenarioGeraldi.pdfStep 1. Read critically and analyze the following scenarioGeraldi.pdf
Step 1. Read critically and analyze the following scenarioGeraldi.pdf
 
Question 3 2 pts In response to the Great Recession, the Federal Rese.pdf
Question 3 2 pts In response to the Great Recession, the Federal Rese.pdfQuestion 3 2 pts In response to the Great Recession, the Federal Rese.pdf
Question 3 2 pts In response to the Great Recession, the Federal Rese.pdf
 
Prove that the T_i -property is a topological property for i = 0S.pdf
Prove that the T_i -property is a topological property for i = 0S.pdfProve that the T_i -property is a topological property for i = 0S.pdf
Prove that the T_i -property is a topological property for i = 0S.pdf
 
Q4.14. Which of the following species is most likely to exhibit pate.pdf
Q4.14. Which of the following species is most likely to exhibit pate.pdfQ4.14. Which of the following species is most likely to exhibit pate.pdf
Q4.14. Which of the following species is most likely to exhibit pate.pdf
 
Prepare a classified balance sheet. Do not show the components that .pdf
Prepare a classified balance sheet. Do not show the components that .pdfPrepare a classified balance sheet. Do not show the components that .pdf
Prepare a classified balance sheet. Do not show the components that .pdf
 
Microscopes and telescopes both consist of two converging lenses cont.pdf
Microscopes and telescopes both consist of two converging lenses cont.pdfMicroscopes and telescopes both consist of two converging lenses cont.pdf
Microscopes and telescopes both consist of two converging lenses cont.pdf
 

Recently uploaded

Smart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICTSmart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICT
simonomuemu
 
Advanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docxAdvanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docx
adhitya5119
 
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
National Information Standards Organization (NISO)
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
Peter Windle
 
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
RitikBhardwaj56
 
How to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP ModuleHow to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP Module
Celine George
 
Pride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School DistrictPride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School District
David Douglas School District
 
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptxChapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
writing about opinions about Australia the movie
writing about opinions about Australia the moviewriting about opinions about Australia the movie
writing about opinions about Australia the movie
Nicholas Montgomery
 
S1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptxS1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptx
tarandeep35
 
Digital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental DesignDigital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental Design
amberjdewit93
 
Main Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docxMain Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docx
adhitya5119
 
DRUGS AND ITS classification slide share
DRUGS AND ITS classification slide shareDRUGS AND ITS classification slide share
DRUGS AND ITS classification slide share
taiba qazi
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
Nguyen Thanh Tu Collection
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
Jean Carlos Nunes Paixão
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
TechSoup
 
How to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold MethodHow to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold Method
Celine George
 
Liberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdfLiberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdf
WaniBasim
 
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective UpskillingYour Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Excellence Foundation for South Sudan
 
PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.
Dr. Shivangi Singh Parihar
 

Recently uploaded (20)

Smart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICTSmart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICT
 
Advanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docxAdvanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docx
 
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
 
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
 
How to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP ModuleHow to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP Module
 
Pride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School DistrictPride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School District
 
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptxChapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
 
writing about opinions about Australia the movie
writing about opinions about Australia the moviewriting about opinions about Australia the movie
writing about opinions about Australia the movie
 
S1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptxS1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptx
 
Digital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental DesignDigital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental Design
 
Main Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docxMain Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docx
 
DRUGS AND ITS classification slide share
DRUGS AND ITS classification slide shareDRUGS AND ITS classification slide share
DRUGS AND ITS classification slide share
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
 
How to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold MethodHow to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold Method
 
Liberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdfLiberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdf
 
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective UpskillingYour Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective Upskilling
 
PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.
 

Create a document with a form that registers all non-profit organiza.pdf

  • 1. Create a document with a form that registers all non-profit organizations in the area, the number of members they have, and the type of organization. After the user enters data in all the fields and presses the button, your program will create a single text le that saves information for each organization on a separate line. The name of the data file is np.txt. This data file should be created in the same directory as your running program, without hard-coding the file path to ensure portability. In the data file please include the Organization name, Membership, and Type, separated by commas. Membership should only accept numbers, Type should only accept the following strings: Educational, Animal Rescue, Religious, Food Service, and misspellings should not be allowed. The first line of the output will be the headers. You can make up all the names and numbers while you are testing your programs. Sample Output written to a file will look as following: Organization, Membership, Type Meals on Trucks, 123, Food Service The Church of Purple Cross, 34, Religious Kitties and Puppies, 1234, Animal Rescue Solution import java.io.BufferedWriter; import java.io.FileWriter; import java.io.IOException; import java.util.Scanner; public class WriteToFile { private static final String FILENAME = "np.txt."; private static Scanner s; static int mem; static String org, type; static int getMem() { System.out.println("Enter Membership Number: "); return s.nextInt(); } public static void main(String[] args) { try (BufferedWriter bw = new BufferedWriter(new FileWriter(FILENAME))) { boolean isMore = true;
  • 2. s = new Scanner(System.in); String content = "Organization, Membership, Type"; bw.write(content); while (isMore) { System.out.println("Enter Organization Name: "); org = s.nextLine(); try { System.out.println("Enter Membership Number: "); mem = s.nextInt(); } catch (Exception e) { System.out.println("Membership Should only be of Number Type"); mem = getMem(); } boolean end = false; do { System.out.println("Enter Type Of Organization: "); type = s.next(); switch (type) { case "Educational": break; case "Animal Rescue": break; case "Religious": break; case "Food Service": break; default: { System.out.println( "Type Name Should be Only Educational, Animal Rescue ,Religious ,Food Service"); end = true; } } } while (end);
  • 3. String f=org+","+mem+","+type; bw.newLine(); bw.append(f); System.out.println("Enter More Enteries?(y/n) :"); if(s.next().equals("n")) isMore=false; } } catch (IOException e) { e.printStackTrace(); } } }