xxxxxxxxxx
const int buzzerPin = 9;
void setup
{
pinmode(buzzer, OUTPUT);
}
void loop ()
{
for (int i = 200; i <= 800; i++)
{
tone (buzzerPin, i);
delay(5)
}
delay(3000);
for (int i = 800; i >=200, i--)
{
tone (buzzerPin, i);
delay(5);
}
}
xxxxxxxxxx
123456789101112131415161718192021222324import java.util.Scanner;public class LeapYear{ public static void main(String[] args) { int lineCounter = 0; for(int year=101; year <= 2100; year++) { if ((year % 4 == 0)) { System.out.println(year + ""); lineCounter++; { if(lineCounter == 10) } System.out.println(""); lineCounter = 0; } } }}X
xxxxxxxxxx
class Test {
public static void main (String [ ] args){
A a = new A("test");
a.print();//No "public class" found to execute
}
}
class A {
String s;
A(String s) {
this.s=s;
}
private void print(){
System.out.println(s);
}
}
xxxxxxxxxx
mplement Method getPercentage that takes two inputs :
grade and totalGrade and outputs the grade percentage
as follows: percentage = (grade/total grade)*100 .
(Assume a student can not get a grade above 100%).
• In the main method use a scanner object to read the grade
and total grade from a text file then pass them to the
getPercentage method.
• The getPercentage method should through:
1. An IllegalArgumentException that is handled by its
caller in case If grade or total grade is a negative
number.
2. An ArithmeticException that is handled by its caller
in case If total grade is zero (division by zero)