Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "java",
"name": "Bonus10",
"request": "launch",
"mainClass": "Bonus10",
"projectName": "Level-1.4_6bb2f5dc"
},
{
"type": "java",
"name": "Bonus",
"request": "launch",
"mainClass": "Bonus",
"projectName": "Level-1.4_6bb2f5dc"
},
{
"type": "java",
"name": "Current File",
"request": "launch",
"mainClass": "${file}"
},
{
"type": "java",
"name": "amica",
"request": "launch",
"mainClass": "amica",
"projectName": "Level-1.4_6bb2f5dc"
}
]
}
4 changes: 4 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,9 @@
"java.project.outputPath": "bin",
"java.project.referencedLibraries": [
"lib/**/*.jar"
],
"cSpell.words": [
"Manea",
"Yahya"
]
}
142 changes: 0 additions & 142 deletions README.md

This file was deleted.

Binary file removed bin/App.class
Binary file not shown.
Binary file added bin/Bonus10.class
Binary file not shown.
Binary file added bin/amica.class
Binary file not shown.
3 changes: 3 additions & 0 deletions count.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
x=''
print(len(x))
#these simple lines help me knowing the beginIndex without any effort
9 changes: 9 additions & 0 deletions infoFile.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
You can change the wanted student by changing the details
Student 1:
Name: Manea Yahya
Math Attendance: 48
Physics Attendance: 42
Chemistry Attendance: 50
Programming Attendance: 45
GPA: 4.12
Excuses: Had a family emergency and went to hospital
5 changes: 0 additions & 5 deletions src/App.java

This file was deleted.

95 changes: 95 additions & 0 deletions src/Bonus10.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
import java.io.FileReader;
import java.io.FileWriter;
import java.util.Scanner;
import java.io.BufferedReader;
import java.io.IOException;
public class Bonus10 {
public static void main(String[] args) throws Exception {
BufferedReader reader = new BufferedReader(new FileReader("C:\\Users\\h4yat\\OneDrive - IMAM ABDULRAHMAN BIN FAISAL UNIVERSITY\\Desktop\\Level-1.4\\Level-1.4\\infoFile.txt"));
FileWriter w = new FileWriter("C:\\Users\\h4yat\\OneDrive - IMAM ABDULRAHMAN BIN FAISAL UNIVERSITY\\Desktop\\Level-1.4\\Level-1.4\\infoFile.txt",true);
Scanner ciao = new Scanner(System.in);
String line, name="", excuse="";
int prog=0, phys=0, math=0, chem=0;
double gpa = 0.0;
boolean Success = true,need=false;
System.out.println("Welcome to the Attendance and Grade System!\nThis is the bonus part of the task\nEvery detail will be taken from the txt file. \nEnjoy!") ;
System.out.println("Student's info: ");
while ((line = reader.readLine()) != null) {
if (line.startsWith("Name: ")) {
name = String.valueOf(line.substring(6).trim());
}
if (line.startsWith("Math Attendance: ")) {
math = Integer.parseInt(line.substring(17).trim());
}
if (line.startsWith("Physics Attendance: ")) {
phys = Integer.parseInt(line.substring(20).trim());
}
if (line.startsWith("Chemistry Attendance: ")) {
chem = Integer.parseInt(line.substring(22).trim());
}
if (line.startsWith("Programming Attendance: ")) {
prog = Integer.parseInt(line.substring(24).trim());
}
if (line.startsWith("GPA: ")) {
gpa = Double.parseDouble(line.substring(5).trim());
need=true;
break;
}
}
System.out.println("The attendance for each subject:");
System.out.println("Math: " + math);
System.out.println("Physics: " + phys);
System.out.println("Chemistry: " + chem);
System.out.println("Programming: " + prog);
System.out.println("Students' GPA: " + gpa);
while(need){
line = reader.readLine(); // read a new line
if (math < 44 || phys < 42 || chem < 40 || prog < 47) {
System.out.print("The excuse of absence: ");
if (line.startsWith("Excuses: ")) {
excuse = String.valueOf(line.substring(9).trim());
System.out.println(excuse);
}
int index = excuse.indexOf("hospital");
if (index != -1) {
math++;prog++;chem++;phys++;
if(math < 44 || phys < 42 || chem < 40 || prog < 47){
Success = false;
}
}
else{
Success = false;
}
}
need=false;
}
System.out.println("\n ---------------------\n \\\\|Student info. updated|//\n ---------------------\n" + //
"\nName: "+name+
"\nMath Attendance: "+math+" days\n" +
"Physics Attendance: "+phys+" days\n" +
"Chemistry Attendance: "+chem+" days\n" +
"Programming Attendance: "+prog+" days\n" +
"Grade: "+gpa+" out of 5");
if(Success){
try{
w.append("\nResult: Congrats! you've success >_<");
w.close();
}
catch(Exception ex){
System.out.println("Can't write in the file");
}
System.out.println("Result: Congrats! you've success >_<");
}
else{
try{
w.append("\nResult: Oops. you failed :'(");
w.close();
}
catch(Exception ex){
System.out.println("Can't write in the file");
}
System.out.println("Result: Oops. you failed :'(");
}
}
}

Binary file added src/amica.class
Binary file not shown.
83 changes: 83 additions & 0 deletions src/amica.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
import java.io.FileReader;
import java.util.Scanner;
import java.io.BufferedReader;

public class amica {
public static void main(String[] args) throws Exception {
/*
Scanner read = new Scanner(System.in);
try{
FileReader R = new FileReader("C:\\Users\\h4yat\\OneDrive - IMAM ABDULRAHMAN BIN FAISAL UNIVERSITY\\Desktop\\infoFile.txt");
int x;
while((x=R.read())!=-1){
System.out.print((char) x);
}
}
catch(Exception ex){}
*/
Scanner ciao = new Scanner(System.in);
System.out.println("Welcome to the Attendance and Grade System!");
System.out.print("Enter your name dear student: ");
String name = ciao.nextLine();
System.out.println("Enter the attendance for each subject:");
//list of variables
int prog, phys, math, chems;
double gpa = 0.0;
boolean Success = true;

System.out.print("Math: ");
math = ciao.nextInt();

System.out.print("Physics: ");
phys = ciao.nextInt();

System.out.print("Chemistry: ");
chems = ciao.nextInt();

System.out.print("Programming: ");
prog = ciao.nextInt();

if (math < 44 || phys < 42 || chems < 40 || prog < 47) {
System.out.print("Enter excuse of absence: ");
String forSpace = ciao.nextLine();
String excuse = ciao.nextLine();
int index = excuse.indexOf("hospital");
if (index != -1) {
math++;prog++;chems++;phys++;
if(math < 44 || phys < 42 || chems < 40 || prog < 47){
Success = false;
}
}
else{
Success = false;
}
}

System.out.print("Students' GPA: ");
/*gpa = ciao.nextDouble();
if(gpa<=3.5){
Success = false;
}*/
BufferedReader reader = new BufferedReader(new FileReader("C:\\Users\\h4yat\\OneDrive - IMAM ABDULRAHMAN BIN FAISAL UNIVERSITY\\Desktop\\infoFile.txt"));
String line;
while ((line = reader.readLine()) != null) {
if (line.startsWith("GPA: ")) {
gpa = Double.parseDouble(line.substring(5).trim());
System.out.println(gpa);
break;
}
}
System.out.println("Student information:\nName"+name+
"\nMath Attendance: "+math+" days\n" +
"Physics Attendance: "+phys+" days\n" +
"Chemistry Attendance: "+chems+" days\n" +
"Programming Attendance: "+prog+" days\n" +
"Grade: "+gpa);
if(Success){
System.out.println("Result: Congrats! you've success");
}
else{
System.out.println("Result: Oops. you failed");
}
}
}