Posts

he challenge here is to read n lines of input until you reach EOF, then number and print all n lines of content. Hint: Java's Scanner.hasNext() method is helpful for this problem.

CSZONE Sample Input Hello world I am a file Read me until end-of-file. Sample Output 1 Hello world 2 I am a file 3 Read me until end-of-file. import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution {     public static void main(String[] args) {         /* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */         Scanner scan = new Scanner(System.in);         int i=1;         while(scan.hasNext()){             System.out.println(i + " " + scan.nextLine());             i++;         }     } }

There are three lines of output: For the first line, sum the lengths of A and B. For the second line, write Yes if A is lexicographically greater than B otherwise print No instead. For the third line, capitalize the first letter in both A and B print them on a single line, separated by a space.

CSZONE import java.io.*; import java.util.*; public class Solution { public static String capitalize(String str){ if(str == null ){ return str; }else{ return str.substring(0,1).toUpperCase()+ str.substring(1).toLowerCase(); } } public static void main(String[] args) { Scanner sc=new Scanner(System.in); String A=sc.next(); String B=sc.next(); /* Enter your code here. Print output to STDOUT. */ System.out.println( A.length()+B.length()); if(A.compareTo(B)>0){ System.out.println("Yes"); }else{ System.out.println("No"); } System.out.println(capitalize(A)+" "+capitalize(B)); } }

In this challenge, we test your knowledge of using if-else conditional statements to automate decision-making processes. An if-else statement has the following logical flow:

CSZONE import java.io.*; import java.math.*; import java.security.*; import java.text.*; import java.util.*; import java.util.concurrent.*; import java.util.regex.*; public class Solution { private static final Scanner scanner = new Scanner(System.in); public static void main(String[] args) { int N = scanner.nextInt(); if(N%2 !=0){ System.out.print("Weird"); }else if(N%2==0 && N >=2 && N<=5){ System.out.print("Not Weird"); }else if(N%2==0 && N >=6 && N<=20){ System.out.print("Weird"); }else if(N%2==0 && N>=20){ System.out.print("Not Weird"); } } }

Task Given the meal price (base cost of a meal), tip percent (the percentage of the meal price being added as tip), and tax percent (the percentage of the meal price being added as tax) for a meal, find and print the meal's total cost.

CSZONE import java.io.*; import java.math.*; import java.security.*; import java.text.*; import java.util.*; import java.util.concurrent.*; import java.util.regex.*; public class Solution { // Complete the solve function below. static void solve(double meal_cost, int tip_percent, int tax_percent) { double total = meal_cost+meal_cost*((tip_percent/100.0)+(tax_percent/100.0)); System.out.print((int) Math.round(total)); } private static final Scanner scanner = new Scanner(System.in); public static void main(String[] args) { double meal_cost = scanner.nextDouble(); int tip_percent = scanner.nextInt(); int tax_percent = scanner.nextInt(); solve(meal_cost, tip_percent, tax_percent); scanner.close(); } }

Ques WAP for exception handling to check user age is eligible to vote or not in java?

Image
import java.util.Scanner;   class AgeException extends Exception {     public AgeException(String str) {   System.out.println(str);   } } public class AgeExcDemo {   public static void main(String[] args) { Scanner s = new Scanner(System.in); System.out.print("Enter Your Age :: "); int age = s.nextInt();   try { if(age < 18)  throw new AgeException("You Are Not Eligible To Vote"); else System.out.println("You Are Eligible  To Vote");   }   catch (AgeException a) { System.out.println(a);   }  } } Download Code  //Output :

C Program For Memory Allocation With Calloc And Free

Image
#include<stdio.h> #include<stdlib.h> #include<conio.h> #include<windows.h> void main(){ int* ptr; int n,i; system("cls"); printf("\n\t\tProgram Of Calloc With Free "); printf("\n\t\tEnter Number of Elements : "); scanf("%d",&n); ptr=(int*) calloc(n,sizeof(int)); if(ptr==NULL){ printf("\n\t\tMemory Not Allocated "); exit(0); }else{ printf("\n\t\tMemory Is Allocated"); printf("\n\t\tGetting elements....."); for (i=0;i<n;i++){ printf("\n\t\t%d : ",i+1); scanf("%d",&ptr[i]); } printf("\n\t\tPrinting Elements\n"); for(i=0;i<n;i++){ printf("\n\t\t%d",ptr[i]); } } free(ptr); printf("\n\n\t\tMemory Free In Calloc\n"); getch(); } //Output:

Send Email Using PHP Mail Function

Image
Code  : -  index.php <html> <head>             <title>Home | CSZONE</title>   <meta charset="UTF-8">   <meta name="description" content="Websit Of CSZONE">   <meta name="keywords" content="HTML,CSS,XML,JavaScript">   <meta name="author" content="CS">   <meta name="viewport" content="width=device-width, initial-scale=1.0">   <meta name="theme-color" content="#DCDCDC" />       <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css"> <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" ></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" ></script> <script src="https://stackpath.boot