NameUpdate

This commit is contained in:
2024-09-17 08:45:27 +02:00
parent 74e421aa7e
commit 9534ee8156
5 changed files with 0 additions and 0 deletions

16
MoreOnClasses/pom.xml Normal file
View File

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.oop</groupId>
<artifactId>more_on_classes</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
</properties>
</project>

View File

@ -0,0 +1,12 @@
package com.oop;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner read = new Scanner(System.in);
int a = read.nextInt();
Pupil pupil = new Pupil();
pupil.setAge(a);
}
}

View File

@ -0,0 +1,29 @@
package com.oop;
// You need a program to manage admissions for an art school. Pupils can be admitted to the school if they are over 6 years of age.
// You're given a program which declares a Pupil class.
// Task
// Complete the setAge method of the Pupil class. If the value of parameter a is over 6, assign it to age attribute and output "Welcome".
// Output "Sorry" otherwise.
// Sample Input
// 7
// Sample Output
// Welcome
public class Pupil {
private int age;
//complete setter method
public void setAge(int a){
if (a > 6) {
age = a;
System.out.println("Welcome");
}else{
System.out.println("Sorry");
}
}
public int getAge(){
return age;
}
}

Binary file not shown.

Binary file not shown.