Skip to content

Commit c942e9d

Browse files
author
EricAgyemang
committed
Introduction_To_Data_Structures_In_Java
0 parents  commit c942e9d

File tree

780 files changed

+27397
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

780 files changed

+27397
-0
lines changed

Arrays/OutputFamilyCellBills.java

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/**
2+
*
3+
*/
4+
package eagyem2.it179;
5+
6+
import java.text.NumberFormat;
7+
import java.util.Scanner;
8+
9+
/**
10+
* @author itstudent
11+
*
12+
*/
13+
public class OutputFamilyCellBills {
14+
15+
/**
16+
* @param args
17+
*/
18+
public static void main(String[] args) {
19+
20+
double [][] familyCellBills = {{45.24, 54.67, 32.55, 25.61},
21+
{65.29, 49.75, 32.08, 26.11},
22+
{75.24, 54.53, 34.55, 28.16}};
23+
24+
String [] months = {"July", "August", "September"};
25+
26+
for(int i = 0; i<months.length; i++)
27+
System.out.println("month " + i + " : "+ months[i]);
28+
Scanner scan = new Scanner(System.in);
29+
30+
int currentMonth;
31+
32+
do {
33+
System.out.println("Enter a month number between 0 and 2 >>");
34+
currentMonth = scan.nextInt();
35+
} while (currentMonth <0 || currentMonth>2);
36+
37+
double monthlyFamilyBills = 0.0;
38+
for(int j = 0; j<familyCellBills[currentMonth].length; j++) {
39+
monthlyFamilyBills +=familyCellBills[currentMonth][j];
40+
}
41+
NumberFormat priceFormat = NumberFormat.getCurrencyInstance();
42+
System.out.println("\nThe total family cell bills during "+ months[currentMonth] + " is "+ priceFormat.format(monthlyFamilyBills));
43+
scan.close();
44+
}
45+
}

Arrays/PrintArrayElements.java

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/**
2+
*
3+
*/
4+
package eagyem2.it179;
5+
6+
/**
7+
* @author itstudent
8+
*
9+
*/
10+
public class PrintArrayElements {
11+
12+
/**
13+
* @param args
14+
*/
15+
public static void main(String[] args) {
16+
17+
double [] cellBills = new double[6];
18+
19+
cellBills[0] = 45.24;
20+
cellBills[1] = 54.67;
21+
cellBills[2] = 42.55;
22+
23+
cellBills[3] = 44.61;
24+
cellBills[4] = 65.29;
25+
cellBills[5] = 49.75;
26+
27+
28+
System.out.println("Element\tValue");
29+
for(int i = 0; i< cellBills.length; i++) {
30+
System.out.println(i+" \t "+cellBills[i]);
31+
}
32+
}
33+
34+
}

Arrays/ReadingDataIntoAnArray.java

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/**
2+
*
3+
*/
4+
package eagyem2.it179;
5+
6+
import java.text.NumberFormat;
7+
import java.util.Scanner;
8+
9+
/**
10+
* @author itstudent
11+
*
12+
*/
13+
public class ReadingDataIntoAnArray {
14+
15+
/**
16+
* @param args
17+
*/
18+
public static void main(String[] args) {
19+
20+
Scanner scan = new Scanner(System.in);
21+
22+
double [] cellBills = new double [6];
23+
24+
double totalBills = 0.0;
25+
26+
for (int i = 0; i < cellBills.length; i++) {
27+
28+
System.out.println("Enter bill amount for month " + (i+1) + "\t");
29+
30+
cellBills[i] = scan.nextDouble();
31+
32+
totalBills += cellBills[i];
33+
}
34+
scan.close();
35+
NumberFormat priceFormat = NumberFormat.getCurrencyInstance();
36+
System.out.println("\nTotal for the bills: " + priceFormat.format(totalBills));
37+
}
38+
39+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/**
2+
*
3+
*/
4+
package eagyem2.it179;
5+
6+
import java.text.NumberFormat;
7+
import java.util.Scanner;
8+
9+
/**
10+
* @author itstudent
11+
*
12+
*/
13+
public class ReadingDataIntoAnArray2 {
14+
15+
/**
16+
* @param args
17+
*/
18+
public static void main(String[] args) {
19+
20+
Scanner scan = new Scanner(System.in);
21+
22+
double [] cellBills = new double [6];
23+
24+
int maxIndex = 0;
25+
int minIndex=0;
26+
for (int i = 0; i < cellBills.length; i++) {
27+
System.out.println("Enter a bill for the month of "+ (i+1)+ "\n");
28+
cellBills[i] = scan.nextDouble();
29+
30+
31+
for(int j = 1; j< cellBills.length; j++) {
32+
if(cellBills[i]> cellBills[maxIndex])
33+
maxIndex=j;
34+
}
35+
36+
for(int u=1; u<cellBills.length; u++) {
37+
if(cellBills[u]<cellBills[minIndex])
38+
minIndex=u;
39+
40+
}
41+
}
42+
scan.close();
43+
NumberFormat priceFormat = NumberFormat.getCurrencyInstance();
44+
System.out.println("\nThe minimum bills is: " + priceFormat.format(cellBills[minIndex]) + ", was found at index " + (minIndex+1));
45+
System.out.println("\nThe highest bills is: " + priceFormat.format(cellBills[maxIndex]) + ", was found at index " + (maxIndex+1));
46+
47+
}
48+
}
5.69 MB
Binary file not shown.
11.3 MB
Binary file not shown.
250 KB
Binary file not shown.
230 KB
Binary file not shown.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"java.project.sourcePaths": ["src"],
3+
"java.project.outputPath": "bin",
4+
"java.project.referencedLibraries": [
5+
"lib/**/*.jar"
6+
]
7+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
## Getting Started
2+
3+
Welcome to the VS Code Java world. Here is a guideline to help you get started to write Java code in Visual Studio Code.
4+
5+
## Folder Structure
6+
7+
The workspace contains two folders by default, where:
8+
9+
- `src`: the folder to maintain sources
10+
- `lib`: the folder to maintain dependencies
11+
12+
Meanwhile, the compiled output files will be generated in the `bin` folder by default.
13+
14+
> If you want to customize the folder structure, open `.vscode/settings.json` and update the related settings there.
15+
16+
## Dependency Management
17+
18+
The `JAVA PROJECTS` view allows you to manage your dependencies. More details can be found [here](https://github.com/microsoft/vscode-java-dependency#manage-dependencies).

0 commit comments

Comments
 (0)