Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package lab.pkg10;
- import java.util.Scanner;
- public class LAB10 {
- public static int numberOfDaysInAYear(int year){
- if(year%4 == 0 && year%400 ==0)
- return 366;
- else return 365;
- }
- public static int count(String str, char a)
- {
- int count = 0;
- for (int i = 0; i < str.length(); i++) {
- if((str.charAt(i))== a)
- {
- count++ ;
- }
- }
- return count;
- }
- public static double m(int n){
- double sum =0;
- for (int i = 1; i <= n; i++) {
- sum -= (double) i/(i+1);
- }
- return sum;
- }
- public static void main(String[] args) {
- Scanner input = new Scanner(System.in);
- /* System.out.println("i\t m(i)");
- System.out.println("---------------");
- for (int i = 1; i <= 20; i++) {
- System.out.printf("3%d\t%.4f\n", i, m(i));
- }
- */
- System.out.println("enter a string and specified character:");
- String str=input.next();
- char a = input.next();
- count(str , a);
- System.out.println("enter a year");
- int year= input.nextInt();
- System.out.println("The nmber of days:" + numberOfDaysInAYear(year));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement