Closed Pankaj-Str closed 11 months ago
package ArrayAssignment;
import java.util.Scanner;
public class Array {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int size = 1;
int max = 100;
String[] product = new String[max];
System.out.println("Enter a Product " + size + " :=");
for (int i = size - 1; i < size; i++) {
product[i] = sc.next();
}
for (int k = 1; k < 100; k++) {
System.out.println("Do you Want to add more [Y/N] :=");
char user = sc.next().charAt(0);
char temp = user;
if (temp == 'n' || temp == 'N') {
k = k + 100;
} else if (temp == 'y' || temp == 'Y') {
size = size + 1;
int m = size - 1;
System.out.println("Enter a Product " + size + " :=");
for (int j = m; j < size; j++) {
product[j] = sc.next();
}
} else {
{
System.out.println("----------->Error<----------");
}
}
}
int price[] = new int[size];
int total = 0;
for (int i = 0; i < size; i++) {
System.out.println("Enter " + product[i] + " Price :=");
price[i] = sc.nextInt();
total = total + price[i];
}
System.out.println("Do you want to add GST [Y/N] := ");
char input = sc.next().charAt(0);
char copy = input;
int gst = 0;
int netgst = 0;
for (int l = 1; l < 100; l++) {
if (copy == 'y' || copy == 'Y') {
System.out.println("Enter GST % :=");
gst = sc.nextInt();
System.out.println("------------");
netgst = (total * gst) / 100; //GST
netgst = total + netgst;
l = l + 100;
} else if (copy == 'n' || copy == 'N') {
System.out.println("------------");
l = l + 100;
} else {
System.out.println("--------->Error<--------");
System.out.println("Do you want to add GST [Y/N] := ");
input = sc.next().charAt(0);
copy = input;
}
}
for (int i = 0; i < size; i++) {
System.out.println((i + 1) + ". " + product[i] + " = " + price[i] + " Rs");
}
System.out.println("------------");
System.out.println("Total := " + total);
if (input == 'y' || input == 'Y') {
System.out.println("GST := " + gst);
System.out.println("------------");
System.out.println("Final Total :=" + netgst);
}
}
}
package Array;
import java.util.Scanner;
public class p1 {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int Maxsize = 50;
String product[] = new String[Maxsize];
int Price[] = new int[Maxsize];
int count = 0;
for (int i = 0; i < Maxsize; i++) {
System.out.println("Enter Product " + (count + 1) + ": ");
product[i] = input.next();
count++;
char ch;
do {
System.out.print("Do you Want to Add More (Y/N): ");
ch = input.next().charAt(0);
if (ch != 'Y' && ch != 'y' && ch != 'N' && ch != 'n') {
System.out.println("Enter a valid option (Y/N): ");
}
} while (ch != 'Y' && ch != 'y' && ch != 'N' && ch != 'n');
if (ch == 'N' || ch == 'n') {
break;
}
}
int sum = 0;
for (int i = 0; i < count; i++) {
System.out.println("Enter " + product[i] + " Price: ");
Price[i] = input.nextInt();
sum += Price[i];
}
double GST = (sum * 18.0) / 100;
int Final_Total = (int) (sum + GST);
char gstChoice;
do {
System.out.print("Do you Want to add GST (Y/N): ");
gstChoice = input.next().charAt(0);
if (gstChoice != 'Y' && gstChoice != 'y' && gstChoice != 'N' && gstChoice != 'n') {
System.out.println("Enter a valid option (Y/N): ");
}
} while (gstChoice != 'Y' && gstChoice != 'y' && gstChoice != 'N' && gstChoice != 'n');
System.out.println("---------Output---------");
for (int i = 0; i < count; i++) {
System.out.println(product[i] + " = " + Price[i] + "/");
}
System.out.println("----------------");
System.out.println("Total = " + sum);
if (gstChoice == 'Y' || gstChoice == 'y') {
System.out.println("GST = 18%");
System.out.println("----------------");
System.out.println("Final Total = " + Final_Total);
}
input.close();
}
}
package Assignments_keerti;
import java.util.Scanner;
public class Day_6_2{ public static void main(String[] args) { System.out.println("Enter the number of items you want to buy"); int size; Scanner sc = new Scanner(System.in); size = sc.nextInt(); String products[] = new String[size]; int cost[] = new int[size];
for (int i = 0; i < size; i++) {
System.out.println("Enter the food item :" + (i + 1) + ": ");
products[i] = sc.next();
}
for (int i = 0; i < size; i++) {
System.out.println("Enter the " + (products[i]) + " price : ");
cost[i] = sc.nextInt();
}
int sum = 0;
for (int i = 0; i < size; i++) {
sum = sum + cost[i];
}
System.out.println("the total cost of your food items is " + sum);
System.out.println("Do you want GST on your bill? [Y] / [N] ");
char selection = sc.next().charAt(0);
if (selection == 'Y') {
System.out.println("If yes then you have to enter the GST of your choice");
int DST = sc.nextInt();
int SST = ((DST*sum)/100); //GST Amount = (Original Cost*GST Rate Percentage) / 100.
int GST=sum+DST;
System.out.println("This is the total bill you have pay : " + GST);
} else if (selection == 'N') {
System.out.println("Your total bill to pay will be: " + sum);
} else {
System.out.println("Please choose only from : [Y] / [N] ");
}
}
}
done (y)
package Core_Java_Projects;
import java.util.Scanner;
public class Advance_billing_system {
// function creating
void while_loop() {
Scanner sc = new Scanner(System.in);
int Maxsize = 100;
// array define here
String product[] = new String[Maxsize];
int Price[] = new int[Maxsize];
int count = 0;
// for loop using
int i = 0;
while (i < Maxsize) {
System.out.println("Enter Product " + (count + 1) + ": ");
i++; // you can write here i = i + 1 also
product[i] = sc.next();
count++;
// intilisize
char ch = 0;
// condition
while (ch != 'Y' && ch != 'y' && ch != 'N' && ch != 'n');
if (ch == 'N' || ch == 'n') {
break;
}{
System.out.print("Do you Want to Add More (Y/N): ");
ch = sc.next().charAt(0);
if (ch != 'Y' && ch != 'y' && ch != 'N' && ch != 'n') {
System.out.println("Enter a valid option (Y/N): ");
}
}
}
int sum = 0;
while (i < count) {
System.out.println("Enter " + product[i] + " Price: ");
Price[i] = sc.nextInt();
sum += Price[i];
i++;
}
float GST = (float) ((sum * 18.0) / 100);
int Final_Total = (int) (sum + GST);
char gstChoice = 0;
while (gstChoice != 'Y' && gstChoice != 'y' && gstChoice != 'N' && gstChoice != 'n') {
System.out.print("Do you Want to add GST (Y/N): ");
gstChoice = sc.next().charAt(0);
if (gstChoice != 'Y' && gstChoice != 'y' && gstChoice != 'N' && gstChoice != 'n') {
System.out.println("Enter a valid option (Y/N): ");
}
}
System.out.println("---------Output---------");
for (i = 0; i < count; i++) {
System.out.println(product[i] + " = " + Price[i] + "/");
}
System.out.println("----------------");
System.out.println("Total = " + sum);
if (gstChoice == 'Y' || gstChoice == 'y') {
System.out.println("GST = 18%");
System.out.println("----------------");
System.out.println("Final Total = " + Final_Total);
}
sc.close();
}
public static void main(String[] args) {
// Main body
Advance_billing_system abs = new Advance_billing_system();
abs.while_loop();
System.out.println("Develop by : Mr suraj");
}
}
OutPut Like this