(Method Create)Create one file by writing ten names and a random number 1 to 60
ID: 3818838 • Letter: #
Question
(Method Create)Create one file by writing ten names and a random number 1 to 60 for an age.So the constant will be 10.
(Method ReadFile) You will need 2 arrays, 1 for the names, and 1 for the ages. Read the names and the ages from the file into the arrays.
(Method Menu) You will have a loop around your menu that can search for a Name or search for an Age.
I'm supposed to be combining these two labs to make the one above:
1:We are going create a file of 10 strings such as last names.
You are going to have to type the names in, then write them to the file.
Then we are going to read the names from the file into an array of strings.
Use a global constant for the limit of the array. Use that constant in all loops.
Print out the array of names, one on a line.
2:1. Create a constant for the length of an array which is equal to 10.
2. Create a file with the name numbers, by writing to the file random integers between 1 and 1000.
3. Declare an array of integers using your constant for the length.
4. Read from the file to fill the array of integers.
5. Declare a Boolean variable that will indicate if a value is found.
6. Declare variables for your LCV, position, and value.
7. Perform the linear search.
8. At the end of the search, print the position in the array and the value found. Print “VALUE NOT FOUND” if the value was not in the array. (Method Create)Create one file by writing ten names and a random number 1 to 60 for an age.
So the constant will be 10.
(Method ReadFile) You will need 2 arrays, 1 for the names, and 1 for the ages. Read the names and the ages from the file into the arrays.
(Method Menu) You will have a loop around your menu that can search for a Name or search for an Age.
I'm supposed to be combining these two labs to make the one above:
1:We are going create a file of 10 strings such as last names.
You are going to have to type the names in, then write them to the file.
Then we are going to read the names from the file into an array of strings.
Use a global constant for the limit of the array. Use that constant in all loops.
Print out the array of names, one on a line.
2:1. Create a constant for the length of an array which is equal to 10.
2. Create a file with the name numbers, by writing to the file random integers between 1 and 1000.
3. Declare an array of integers using your constant for the length.
4. Read from the file to fill the array of integers.
5. Declare a Boolean variable that will indicate if a value is found.
6. Declare variables for your LCV, position, and value.
7. Perform the linear search.
8. At the end of the search, print the position in the array and the value found. Print “VALUE NOT FOUND” if the value was not in the array. (Method Create)Create one file by writing ten names and a random number 1 to 60 for an age.
So the constant will be 10.
(Method ReadFile) You will need 2 arrays, 1 for the names, and 1 for the ages. Read the names and the ages from the file into the arrays.
(Method Menu) You will have a loop around your menu that can search for a Name or search for an Age.
I'm supposed to be combining these two labs to make the one above:
1:We are going create a file of 10 strings such as last names.
You are going to have to type the names in, then write them to the file.
Then we are going to read the names from the file into an array of strings.
Use a global constant for the limit of the array. Use that constant in all loops.
Print out the array of names, one on a line.
2:1. Create a constant for the length of an array which is equal to 10.
2. Create a file with the name numbers, by writing to the file random integers between 1 and 1000.
3. Declare an array of integers using your constant for the length.
4. Read from the file to fill the array of integers.
5. Declare a Boolean variable that will indicate if a value is found.
6. Declare variables for your LCV, position, and value.
7. Perform the linear search.
8. At the end of the search, print the position in the array and the value found. Print “VALUE NOT FOUND” if the value was not in the array.
Explanation / Answer
import java.util.Scanner;
/**
*
* @author Arun V Jacob
*/
public class StudentDetails {
String name,clas;
int roll,age,a,b,c,d,e;
double percentage,total;
Scanner s= new Scanner(System.in);
void enter()
{
System.out.println("*** Enter Details of the student ***");
System.out.println(" Enter the name of the student");
name= s.next();
System.out.println(" Enter the age of the student");
age= s.nextInt();
System.out.println(" Enter the class");
clas= s.next();
System.out.println(" Enter the Roll No.");
roll= s.nextInt();
System.out.println(" Enter mark Obtained by the student ---SUBJECTS--- 1. Physics");
a= s.nextInt();
System.out.println(" 2. Chemistry");
b= s.nextInt();
System.out.println(" 3. Maths");
c= s.nextInt();
System.out.println(" 4. Electronics");
d= s.nextInt();
System.out.println(" 5. Java");
e= s.nextInt();
}
void display()
{
System.out.println("*** Details of the student ***");
System.out.println(" Name of the student : "+name);
System.out.println(" Student age : "+age);
System.out.println(" Class : "+clas);
System.out.println(" Roll No. : "+roll);
System.out.println(" Mark obtained 1.Physics : "+a+" 2. Chemistry : "+b);
System.out.println(" 3. Maths : "+c+" 4. Electronics"+d+" 5. Java"+e);
}
void calculation()
{
total= a+b+c+d+e;
percentage= (total/500)*100;
System.out.println(" Total mark obtained by student out of 500 : "+total);
System.out.println(" Percentage of Mark : "+percentage);
}
public static void main(String[] args) {
StudentDetails obj= new StudentDetails();
obj.enter();
obj.display();
obj.calculation();
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.