Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
30564e7
Create find lattice in C
rashmiedirisuriya97 Oct 22, 2021
3fa59ef
Create Electricity Bill code by creating a Separate class
rashmiedirisuriya97 Oct 22, 2021
7ab88bb
Merge pull request #1 from rashmiedirisuriya97/rashmiedirisuriya97-pa…
rashmiedirisuriya97 Oct 22, 2021
81b51ab
Create find a lattic in C
rashmiedirisuriya97 Oct 22, 2021
104b589
Merge pull request #2 from rashmiedirisuriya97/rashmiedirisuriya97-pa…
rashmiedirisuriya97 Oct 22, 2021
b9e86e6
Create c++ fibonachchi
rashmiedirisuriya97 Oct 22, 2021
2d7137c
Merge pull request #3 from rashmiedirisuriya97/rashmiedirisuriya97-pa…
rashmiedirisuriya97 Oct 22, 2021
4f2ad4b
Create Hacktoberfest2021 Find A Lattice in C
rashmiedirisuriya97 Oct 22, 2021
643b89f
Create C- find lattice
rashmiedirisuriya97 Oct 22, 2021
cc53df6
Create flutter custom appbar
rashmiedirisuriya97 Oct 22, 2021
3437652
Merge pull request #4 from rashmiedirisuriya97/rashmiedirisuriya97-pa…
rashmiedirisuriya97 Oct 22, 2021
796ca9b
Create Fibonacci Series in C#
rashmiedirisuriya97 Oct 22, 2021
1c36de0
Merge pull request #5 from rashmiedirisuriya97/rashmiedirisuriya97-pa…
rashmiedirisuriya97 Oct 22, 2021
c5a01cf
Create Scientific Calculator in C#
rashmiedirisuriya97 Oct 22, 2021
2a527b9
Merge pull request #6 from rashmiedirisuriya97/rashmiedirisuriya97-pa…
rashmiedirisuriya97 Oct 22, 2021
c876401
Create Snake game in C#
rashmiedirisuriya97 Oct 22, 2021
6267d2d
Merge pull request #7 from rashmiedirisuriya97/rashmiedirisuriya97-pa…
rashmiedirisuriya97 Oct 22, 2021
d84b53e
Create Simple Calculator in java
rashmiedirisuriya97 Oct 22, 2021
8976e5a
Merge pull request #8 from rashmiedirisuriya97/rashmiedirisuriya97-pa…
rashmiedirisuriya97 Oct 22, 2021
4317753
Create Puzzle Game in Java
rashmiedirisuriya97 Oct 22, 2021
26ac4f1
Merge pull request #9 from rashmiedirisuriya97/rashmiedirisuriya97-pa…
rashmiedirisuriya97 Oct 22, 2021
295ec2a
Create Bookstore Application in java
rashmiedirisuriya97 Oct 22, 2021
40d0680
Merge pull request #10 from rashmiedirisuriya97/rashmiedirisuriya97-p…
rashmiedirisuriya97 Oct 22, 2021
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
114 changes: 114 additions & 0 deletions Bookstore Application in java
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
import java.util.*;

class Books {
public String title;
public String author;
public int isbn;
public double price;
public double discount;
public double total;

public Books() {
}

public Books(String title, String author, int isbn, double price,
double discount, double total) {
super();
this.title = title;
this.author = author;
this.isbn = isbn;
this.price = price;
this.discount = discount;
this.total = total;
}

public String getTitle() {
return title;
}

public String getAuthor() {
return author;
}

public int getIsbn() {
return isbn;
}

public double getPrice() {
return price;
}

public double getDiscount() {
return discount;
}

public double getTotal() {
return total;
}
}

public class BookStore {
public static void main(String[] args) throws Exception {
double amount = 0.0;
double sum = 0.0;
int count = 1;
List list = new ArrayList();
Scanner scan = new Scanner(System.in);
int menu = 0;
System.out.println("Book Store");
System.out.println();
System.out.println("1. Buy book");
System.out.println("2. Receipt");
System.out.println("3. Receive Payment");
System.out.println("4. Exit");
boolean quit = false;
do {
if (count > 5) {
System.out
.println("You cannot buy more than 5 books at a time.");
}
System.out.print("Please enter your choice: ");
menu = scan.nextInt();
System.out.println();
switch (menu) {
case 1:
count++;
System.out.println("Book Title: ");
String booktitle = scan.next();
System.out.println("Author: ");
String auth = scan.next();
System.out.println("ISBN: ");
int no = scan.nextInt();
System.out.println("Price: ");
double p = scan.nextDouble();
System.out.println("Discount: ");
double dis = scan.nextDouble();
double total = p - (dis * p);
list.add(new Books(booktitle,auth, no, p,dis, total));
break;
case 2:
System.out.println("Title Author ISBN Price
Discount Total");
for (Books s : list) {
System.out.println(s.getTitle() + " " + s.getAuthor()
+ " " + s.getIsbn() + " "+ s.getPrice() + " "+
s.getDiscount() + " " + s.getTotal());
sum += s.getTotal();
}
System.out.println("Total= " + sum);
break;
case 3:
System.out.println("Customer Pays: ");
amount = scan.nextDouble();
double balance = amount - sum;
System.out.println("Balance is: " + balance);
quit = true;
case 4:
quit = true;
break;
default:
System.out.println("Invalid Entry!");
}
} while (!quit);
}
}
83 changes: 83 additions & 0 deletions C- find lattice
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
#include <stdlib.h>
#include <stdio.h>


int array[100], c, arrayLength,i,j,gcd,g,k,l,fi;

int findValue(int toSearch){

int found = 0;

for( fi=0; fi<arrayLength; fi++)
{

if(array[fi] == toSearch)
{
found = 1;
break;
}
}


if(found==0){
printf("\n======================");
printf("\nThis is not a Lattice");
printf("\n======================");
_Exit(0);
}

return 0;
}

void checkLattice(){
printf("\nChecking lattice...");
//check GLU and LUB
for ( i = 0; i < arrayLength; i++){
for ( j = 0; j < arrayLength; j++){

//find GCD
int n1=array[i];
int n2=array[j];
for(g=1; g <= n1 && g <= n2; ++g)
{
// Checks if g is factor of both integers
if(n1%g==0 && n2%g==0){

gcd = g;

}
}
int lcm = ((n1*n2)/gcd);
printf("\nn1 = %d, n2 = %d, GCD = %d, LCM = %d",n1,n2,gcd,lcm);
int a = findValue(gcd);
int b = findValue(lcm);
}
}

printf("\n======================");
printf("\nThis is a Lattice");
printf("\n======================");
}

int main()
{

printf("Enter number of elements in array\n");
scanf("%d", &arrayLength);

printf("Enter %d elements\n", arrayLength);

for (c = 0; c < arrayLength; c++){
scanf("%d", &array[c]);
}

printf("Entered array is\n");

for (c = 0; c < arrayLength; c++){
printf("%d, ", array[c]);
}

checkLattice();

return 0;
}
68 changes: 68 additions & 0 deletions Electricity Bill code by creating a Separate class
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import java.util.*;
class CalculateElectricityBill
{
double billpay;

CalculateElectricityBill(long units)
{
if(units<100)
billpay=units*1.20;
else if(units<=300)
billpay=100*1.20+(units-100)*2;
else if(units>300)
billpay=100*1.20+200 *2+(units-300)*3;

}


}
class ComputeElectricityBill
{
public static void main(String args[])
{
long units;

Scanner sc=new Scanner(System.in);

System.out.println("enter number of units");

units=sc.nextLong();

CalculateElectricityBill b=new CalculateElectricityBill(units);

System.out.println("Bill to pay : " + b.billpay);
}
}
35 changes: 35 additions & 0 deletions Fibonacci Series in C#
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace test
{
class Program
{
static long[] numbers;

static long Fib(int n)
{
if (0 == numbers[n])
{
numbers[n] = Fib(n - 1) + Fib(n - 2);
}
return numbers[n];
}


static void Main()
{
Console.Write("n = ");
int n = int.Parse(Console.ReadLine());
numbers = new long[n + 2];
numbers[1] = 1;
numbers[2] = 1;
long result = Fib(n);
Console.WriteLine("fib({0}) = {1}", n, result);
Console.ReadKey();
}
}
}
83 changes: 83 additions & 0 deletions Hacktoberfest2021 Find A Lattice in C
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
#include <stdlib.h>
#include <stdio.h>


int array[100], c, arrayLength,i,j,gcd,g,k,l,fi;

int findValue(int toSearch){

int found = 0;

for( fi=0; fi<arrayLength; fi++)
{

if(array[fi] == toSearch)
{
found = 1;
break;
}
}


if(found==0){
printf("\n======================");
printf("\nThis is not a Lattice");
printf("\n======================");
_Exit(0);
}

return 0;
}

void checkLattice(){
printf("\nChecking lattice...");
//check GLU and LUB
for ( i = 0; i < arrayLength; i++){
for ( j = 0; j < arrayLength; j++){

//find GCD
int n1=array[i];
int n2=array[j];
for(g=1; g <= n1 && g <= n2; ++g)
{
// Checks if g is factor of both integers
if(n1%g==0 && n2%g==0){

gcd = g;

}
}
int lcm = ((n1*n2)/gcd);
printf("\nn1 = %d, n2 = %d, GCD = %d, LCM = %d",n1,n2,gcd,lcm);
int a = findValue(gcd);
int b = findValue(lcm);
}
}

printf("\n======================");
printf("\nThis is a Lattice");
printf("\n======================");
}

int main()
{

printf("Enter number of elements in array\n");
scanf("%d", &arrayLength);

printf("Enter %d elements\n", arrayLength);

for (c = 0; c < arrayLength; c++){
scanf("%d", &array[c]);
}

printf("Entered array is\n");

for (c = 0; c < arrayLength; c++){
printf("%d, ", array[c]);
}

checkLattice();

return 0;
}
Loading